Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-09-19 17:25:36
Exec Total Coverage
Lines: 1673 4374 38.2%
Functions: 130 337 38.6%
Branches: 925 2902 31.9%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
70
71 extern byte monochrome_console;
72
73 extern HeroClass Hero;
74 extern ZModule zcm;
75 extern zcmodule moduledata;
76 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
77 extern particle_list particles;
78 extern int32_t loadlast;
79 extern char *sfx_string[WAV_COUNT];
80 byte use_dwm_flush;
81 byte use_save_indicator;
82 int32_t paused_midi_pos = 0;
83 byte midi_suspended = 0;
84 byte zc_192b163_warp_compatibility;
85 char modulepath[2048];
86 bool epilepsyFlashReduction;
87 signed char pause_in_background_menu_init = 0;
88 byte pause_in_background = 0;
89 bool is_sys_pal = false;
90 static bool load_control_called_this_frame;
91 extern PALETTE* hw_palette;
92 extern bool update_hw_pal;
93 extern const char* dmaplist(int32_t index, int32_t* list_size);
94 int32_t getnumber(const char *prompt,int32_t initialval);
95
96 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
97 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
98 //extern byte refresh_select_screen;
99 //extern movingblock mblock2; //mblock[4]?
100 //extern int32_t db;
101
102 static const char *ZC_str = "ZQuest Classic";
103 #if defined(ALLEGRO_WINDOWS)
104 const char *qst_dir_name = "win_qst_dir";
105 static const char *qst_module_name = "current_module";
106 #elif defined(ALLEGRO_LINUX)
107 const char *qst_dir_name = "linux_qst_dir";
108 static const char *qst_module_name = "current_module";
109 #elif defined(__APPLE__)
110 const char *qst_dir_name = "osx_qst_dir";
111 static const char *qst_module_name = "current_module";
112 #endif
113 #ifdef ALLEGRO_LINUX
114 static const char *samplepath = "samplesoundset/patches.dat";
115 #endif
116 char qst_files_path[2048];
117
118 #ifdef _MSC_VER
119 #define getcwd _getcwd
120 #endif
121
122 bool rF11();
123 bool rI();
124 bool rQ();
125 bool zc_key_pressed();
126
127 #ifdef _WIN32
128
129 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
130 extern "C"
131 {
132 typedef HRESULT(WINAPI *t_DwmFlush)();
133 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
134 }
135
136 void do_DwmFlush()
137 {
138 static HMODULE shell = LoadLibrary("dwmapi.dll");
139
140 if(!shell)
141 return;
142
143 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
144 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
145
146 BOOL enabled;
147 isEnabled(&enabled);
148
149 if(isEnabled)
150 flush();
151 }
152
153 #endif // _WIN32
154
155 83751 bool flash_reduction_enabled(bool check_qr)
156 {
157
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
158 }
159
160 // Dialogue largening
161 void large_dialog(DIALOG *d)
162 {
163 large_dialog(d, 1.5);
164 }
165
166 void large_dialog(DIALOG *d, float RESIZE_AMT)
167 {
168 if(!d[0].d1)
169 {
170 d[0].d1 = 1;
171 int32_t oldwidth = d[0].w;
172 int32_t oldheight = d[0].h;
173 int32_t oldx = d[0].x;
174 int32_t oldy = d[0].y;
175 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
176 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
177 d[0].w = int32_t(d[0].w*RESIZE_AMT);
178 d[0].h = int32_t(d[0].h*RESIZE_AMT);
179
180 for(int32_t i=1; d[i].proc !=NULL; i++)
181 {
182 // Place elements horizontally
183 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
184 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
185
186 if(d[i].proc != d_stringloader)
187 {
188 if(d[i].proc==d_bitmap_proc)
189 {
190 d[i].w *= 2;
191 }
192 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
193 }
194
195 // Place elements vertically
196 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
197 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
198
199 // Vertically resize elements
200 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
201 {
202 d[i].h = int32_t((double)d[i].h*1.5);
203 }
204 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
205 {
206 d[i].y += int32_t((double)d[i].h*0.25);
207 d[i].h = int32_t((double)d[i].h*1.25);
208 }
209 else if(d[i].proc==d_bitmap_proc)
210 {
211 d[i].h *= 2;
212 }
213 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
214
215 // Fix frames
216 if(d[i].proc == jwin_frame_proc)
217 {
218 d[i].x++;
219 d[i].y++;
220 d[i].w-=4;
221 d[i].h-=4;
222 }
223 }
224 }
225
226 for(int32_t i=1; d[i].proc!=NULL; i++)
227 {
228 if(d[i].proc==jwin_slider_proc)
229 continue;
230
231 // Bigger font
232 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
233
234 if(!d[i].dp2 && bigfontproc)
235 {
236 d[i].dp2 = get_zc_font(font_lfont_l);
237 }
238 else if(!bigfontproc)
239 {
240 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
241 }
242
243 // Make checkboxes work
244 if(d[i].proc == jwin_check_proc)
245 d[i].proc = jwin_checkfont_proc;
246 else if(d[i].proc == jwin_radio_proc)
247 d[i].proc = jwin_radiofont_proc;
248 }
249
250 jwin_center_dialog(d);
251 }
252
253
254 /**********************************/
255 /******** System functions ********/
256 /**********************************/
257
258 static char cfg_sect[] = "zeldadx"; //We need to rename this.
259 static char ctrl_sect[] = "Controls";
260 static char sfx_sect[] = "Volume";
261
262 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
263 {
264 return D_O_K;
265 }
266
267 bool is_reserved_key(int c)
268 {
269 switch(c)
270 {
271 case KEY_ESC:
272 return true;
273 }
274 return false;
275 }
276 bool is_reserved_keycombo(int c, int modflag)
277 {
278 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
279 return true;
280 return false;
281 }
282 bool checkcheat(Cheat cheat)
283 {
284 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
285 return true; //Main key pressed
286 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
287 return true; //Alt key pressed
288 return false;
289 }
290 116 void load_default_cheatkeys()
291 {
292 116 memset(cheatkeys, 0, sizeof(cheatkeys));
293 116 cheatkeys[Cheat::Life][0] = KEY_H;
294 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
295 116 cheatkeys[Cheat::Magic][0] = KEY_M;
296 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
297 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
298 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
299 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
300 116 cheatkeys[Cheat::Clock][0] = KEY_I;
301 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
302 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
303 116 cheatkeys[Cheat::Light][0] = KEY_L;
304 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
305 116 cheatkeys[Cheat::Kill][0] = KEY_K;
306 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
307 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
308 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
309 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
310 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
311 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
312 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
313 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
314 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
315 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
316 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
317 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
318 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
319 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
320 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
321 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
322 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
323 116 }
324 116 void load_game_configs()
325 {
326 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
327 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
328 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
329 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
330 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
331 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
332 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
333 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
334 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
335 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
336 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
337 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
338 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
339 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
340 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
341
342 //cheat modifier keya
343 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
344 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
345 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
346 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
347
348 //cheat keys
349 116 load_default_cheatkeys();
350 char buf[256];
351
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 116 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
352 {
353
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
354 4060 std::string cheatname = cheat_to_string((Cheat)q);
355
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
356 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
357
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
358 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
359
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
360 4060 }
361
362
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
363 joystick_index = 0;
364
365 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
366 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
367 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
368 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
369 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
370 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
371 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
372 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
373 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
374 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
375
376 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
377 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
378 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
379 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
380
381 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
382 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
383 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
384 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
385 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
386 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
387 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
388 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
389 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
390 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
391 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
392
393 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
394 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
395 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
396 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
397
398 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
399
400 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
401 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
402 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
403 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
404 116 pan_style = zc_get_config(sfx_sect,"pan",1);
405 // 1 <= zcmusic_bufsz <= 128
406 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
407 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
408 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
409 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
410 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
411 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
412 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
413 #ifdef __EMSCRIPTEN__
414 if (em_is_mobile()) NameEntryMode = 2;
415 #endif
416 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
417 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
418 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
419 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
420 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
421
422 //default - scale x2, 640 x 480
423 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
424 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
425 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
426 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
427 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
428 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
429 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
430
431 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
432
433 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
434
435 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
436
437 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
438 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
439 #ifdef _WIN32
440 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
441 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
442 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
443 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
444
445 // This one's for Aero
446 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
447
448 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
449 #else //UNIX
450 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
451 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
452 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
453 #endif
454 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
455 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
456
457 116 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
458
459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(strlen(qstdir)==0)
460 {
461 116 getcwd(qstdir,2048);
462 116 fix_filename_case(qstdir);
463 116 fix_filename_slashes(qstdir);
464 116 put_backslash(qstdir);
465 116 }
466 else
467 {
468 chop_path(qstdir);
469 }
470
471 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
472 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
473 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
474 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
475 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
476 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
477 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
478 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
479 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
480 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
481 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
482 116 }
483
484 void save_control_configs(bool kb)
485 {
486 if(kb)
487 {
488 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
489 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
490 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
491 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
492
493 if (!replay_is_replaying())
494 {
495 zc_set_config(ctrl_sect,"key_a",Akey);
496 zc_set_config(ctrl_sect,"key_b",Bkey);
497 zc_set_config(ctrl_sect,"key_s",Skey);
498 zc_set_config(ctrl_sect,"key_l",Lkey);
499 zc_set_config(ctrl_sect,"key_r",Rkey);
500 zc_set_config(ctrl_sect,"key_p",Pkey);
501 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
502 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
503 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
504 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
505 zc_set_config(ctrl_sect,"key_up", DUkey);
506 zc_set_config(ctrl_sect,"key_down", DDkey);
507 zc_set_config(ctrl_sect,"key_left", DLkey);
508 zc_set_config(ctrl_sect,"key_right",DRkey);
509 }
510 }
511 else
512 {
513 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
514 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
515 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
516 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
517 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
518 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
519 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
520 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
527
528 zc_set_config(ctrl_sect,"btn_a",Abtn);
529 zc_set_config(ctrl_sect,"btn_b",Bbtn);
530 zc_set_config(ctrl_sect,"btn_s",Sbtn);
531 zc_set_config(ctrl_sect,"btn_m",Mbtn);
532 zc_set_config(ctrl_sect,"btn_l",Lbtn);
533 zc_set_config(ctrl_sect,"btn_r",Rbtn);
534 zc_set_config(ctrl_sect,"btn_p",Pbtn);
535 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
536 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
537 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
538 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
539
540 zc_set_config(ctrl_sect,"btn_up",DUbtn);
541 zc_set_config(ctrl_sect,"btn_down",DDbtn);
542 zc_set_config(ctrl_sect,"btn_left",DLbtn);
543 zc_set_config(ctrl_sect,"btn_right",DRbtn);
544 }
545 }
546
547 void save_cheatkeys()
548 {
549 char buf[256];
550 for(size_t q = 1; q < Cheat::Last; ++q)
551 {
552 if(!bindable_cheat((Cheat)q)) continue;
553 std::string cheatname = cheat_to_string((Cheat)q);
554 util::lowerstr(cheatname);
555 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
556 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
557 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
558 if(cheatkeys[q][1])
559 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
560 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
561 }
562 }
563
564 void save_game_configs()
565 {
566 packfile_password("");
567
568 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
569
570 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
571 {
572 int o_window_x, o_window_y;
573 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
574 zc_set_config(cfg_sect,"window_x",o_window_x);
575 zc_set_config(cfg_sect,"window_y",o_window_y);
576 }
577
578 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
579 {
580 double monitor_scale = zc_get_monitor_scale();
581 window_width = al_get_display_width(all_get_display()) / monitor_scale;
582 window_height = al_get_display_height(all_get_display()) / monitor_scale;
583 zc_set_config(cfg_sect,"window_width",window_width);
584 zc_set_config(cfg_sect,"window_height",window_height);
585 }
586
587 zc_set_config(cfg_sect,"load_last",loadlast);
588 chop_path(qstdir);
589 zc_set_config(cfg_sect,qst_dir_name,qstdir);
590 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
591
592 flush_config_file();
593 #ifdef __EMSCRIPTEN__
594 em_sync_fs();
595 #endif
596 }
597
598 //----------------------------------------------------------------
599
600 // Timers
601
602 29903 void fps_callback()
603 {
604 29903 lastfps=framecnt;
605 29903 dword tempsecs = fps_secs;
606 29903 ++tempsecs;
607 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
608 29903 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
609 29903 ++fps_secs;
610 29903 framecnt=0;
611 29903 }
612
613 END_OF_FUNCTION(fps_callback)
614
615 116 int32_t Z_init_timers()
616 {
617 static bool didit = false;
618 const static char *err_str = "Couldn't allocate timer";
619 116 err_str = err_str; //Unused variable warning
620
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
622 return 1;
623
624 116 didit = true;
625
626 LOCK_VARIABLE(lastfps);
627 LOCK_VARIABLE(framecnt);
628 LOCK_FUNCTION(fps_callback);
629
630
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
631 return 0;
632
633 116 return 1;
634 116 }
635
636 void Z_remove_timers()
637 {
638 remove_int(fps_callback);
639 }
640
641 //----------------------------------------------------------------
642
643 void go()
644 {
645 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
646 }
647
648 void comeback()
649 {
650 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
651 }
652
653 void dump_pal(BITMAP *dest)
654 {
655 for(int32_t i=0; i<256; i++)
656 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
657 }
658
659 //----------------------------------------------------------------
660
661 int game_mouse_index = ZCM_BLANK;
662 static bool system_mouse = false;
663 28 bool sys_mouse()
664 {
665 28 system_mouse = true;
666 28 return MouseSprite::set(ZCM_NORMAL);
667 }
668 559 bool game_mouse()
669 {
670 559 system_mouse = false;
671 559 return MouseSprite::set(game_mouse_index);
672 }
673 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
674 {
675 if(!bmp)
676 return;
677 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
678 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
679 if(bmp->w == scaledw && bmp->h == scaledh)
680 user_scale = false;
681 if(user_scale || sys_recolor)
682 {
683 if(!user_scale) scale = 1;
684 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
685 if(user_scale)
686 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
687 else
688 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
689 if(sys_recolor)
690 recolor_mouse(tmpbmp);
691 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
692 destroy_bitmap(tmpbmp);
693 }
694 else
695 {
696 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
697 }
698 }
699
700 //Handles converting the mouse sprite from the .dat file
701 void recolor_mouse(BITMAP* bmp)
702 {
703 for(int32_t x = 0; x < bmp->w; ++x)
704 {
705 for(int32_t y = 0; y < bmp->h; ++y)
706 {
707 int32_t color = getpixel(bmp, x, y);
708 switch(color)
709 {
710 case dvc(1):
711 color = jwin_pal[jcCURSORMISC];
712 break;
713 case dvc(2):
714 color = jwin_pal[jcCURSOROUTLINE];
715 break;
716 case dvc(3):
717 color = jwin_pal[jcCURSORLIGHT];
718 break;
719 case dvc(5):
720 color = jwin_pal[jcCURSORDARK];
721 break;
722 default:
723 continue;
724 }
725 putpixel(bmp, x, y, color);
726 }
727 }
728 }
729 void load_mouse()
730 {
731 enter_sys_pal();
732 MouseSprite::set(-1);
733 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
734 int32_t sz = 16*scale;
735 for(int32_t j = 0; j < 1; ++j)
736 {
737 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
738 if(zcmouse[j])
739 destroy_bitmap(zcmouse[j]);
740 zcmouse[j] = create_bitmap_ex(8,sz,sz);
741 clear_bitmap(zcmouse[j]);
742 clear_bitmap(tmpbmp);
743 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
744 recolor_mouse(tmpbmp);
745 if(sz!=16)
746 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
747 else
748 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
749 destroy_bitmap(tmpbmp);
750 }
751 if(!hw_palette) hw_palette = &RAMpal;
752 zc_set_palette(*hw_palette);
753
754 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
755 clear_bitmap(blankmouse);
756
757 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
758 MouseSprite::assign(ZCM_BLANK, blankmouse);
759 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
760
761 //Reload the mouse
762 if(system_mouse)
763 sys_mouse();
764 else game_mouse();
765
766 destroy_bitmap(blankmouse);
767 exit_sys_pal();
768 }
769
770 // sets the video mode and initializes the palette and mouse sprite
771 116 bool game_vid_mode(int32_t mode,int32_t wait)
772 {
773
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
774 116 return true;
775
776 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
777 {
778 return false;
779 }
780
781 scrx = (resx-320)>>1;
782 scry = (resy-240)>>1;
783 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
784 zcmouse[q] = NULL;
785 load_mouse();
786
787 for(int32_t i=240; i<256; i++)
788 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
789
790 zc_set_palette(RAMpal);
791 clear_to_color(screen,BLACK);
792
793 rest(wait);
794 return true;
795 116 }
796
797 8 void null_quest()
798 {
799 char qstdat_string[2048];
800 8 strcpy(qstdat_string, "modules/classic/default.qst");
801
802 #ifdef __EMSCRIPTEN__
803 // The quest template data file is not included because it's really big and isn't really needed
804 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
805 // which is much smaller.
806 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
807 #endif
808
809 8 byte skip_flags[4] = { 0 };
810
811 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
812 8 }
813
814 8 void init_NES_mode()
815 {
816 8 null_quest();
817 8 }
818
819 //----------------------------------------------------------------
820
821 qword trianglelines[16]=
822 {
823 0x0000000000000000ULL,
824 0xFD00000000000000ULL,
825 0xFDFD000000000000ULL,
826 0xFDFDFD0000000000ULL,
827 0xFDFDFDFD00000000ULL,
828 0xFDFDFDFDFD000000ULL,
829 0xFDFDFDFDFDFD0000ULL,
830 0xFDFDFDFDFDFDFD00ULL,
831 0xFDFDFDFDFDFDFDFDULL,
832 0x00FDFDFDFDFDFDFDULL,
833 0x0000FDFDFDFDFDFDULL,
834 0x000000FDFDFDFDFDULL,
835 0x00000000FDFDFDFDULL,
836 0x0000000000FDFDFDULL,
837 0x000000000000FDFDULL,
838 0x00000000000000FDULL,
839 };
840
841 word screen_triangles[28][32];
842 /*
843 qword triangles[4][16]= //[direction][value]
844 {
845 {
846 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
847 },
848 {
849 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
850 },
851 {
852 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
853 },
854 {
855 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
856 }
857 };
858 */
859
860
861 /*
862 byte triangles[4][16][8]= //[direction][value][line]
863 {
864 {
865 {
866 0, 0, 0, 0, 0, 0, 0, 0
867 },
868 {
869 1, 0, 0, 0, 0, 0, 0, 0
870 },
871 {
872 2, 1, 0, 0, 0, 0, 0, 0
873 },
874 {
875 3, 2, 1, 0, 0, 0, 0, 0
876 },
877 {
878 4, 3, 2, 1, 0, 0, 0, 0
879 },
880 {
881 5, 4, 3, 2, 1, 0, 0, 0
882 },
883 {
884 6, 5, 4, 3, 2, 1, 0, 0
885 },
886 {
887 7, 6, 5, 4, 3, 2, 1, 0
888 },
889 {
890 8, 7, 6, 5, 4, 3, 2, 1
891 },
892 {
893 8, 8, 7, 6, 5, 4, 3, 2
894 },
895 {
896 8, 8, 8, 7, 6, 5, 4, 3
897 },
898 {
899 8, 8, 8, 8, 7, 6, 5, 4
900 },
901 {
902 8, 8, 8, 8, 8, 7, 6, 5
903 },
904 {
905 8, 8, 8, 8, 8, 8, 7, 6
906 },
907 {
908 8, 8, 8, 8, 8, 8, 8, 7
909 },
910 {
911 8, 8, 8, 8, 8, 8, 8, 8
912 }
913 },
914 {
915 {
916 0, 0, 0, 0, 0, 0, 0, 0
917 },
918 {
919 15, 0, 0, 0, 0, 0, 0, 0
920 },
921 {
922 14, 15, 0, 0, 0, 0, 0, 0
923 },
924 {
925 13, 14, 15, 0, 0, 0, 0, 0
926 },
927 {
928 12, 13, 14, 15, 0, 0, 0, 0
929 },
930 {
931 11, 12, 13, 14, 15, 0, 0, 0
932 },
933 {
934 10, 11, 12, 13, 14, 15, 0, 0
935 },
936 {
937 9, 10, 11, 12, 13, 14, 15, 0
938 },
939 {
940 8, 9, 10, 11, 12, 13, 14, 15
941 },
942 {
943 8, 8, 9, 10, 11, 12, 13, 14
944 },
945 {
946 8, 8, 8, 9, 10, 11, 12, 13
947 },
948 {
949 8, 8, 8, 8, 9, 10, 11, 12
950 },
951 {
952 8, 8, 8, 8, 8, 9, 10, 11
953 },
954 {
955 8, 8, 8, 8, 8, 8, 9, 10
956 },
957 {
958 8, 8, 8, 8, 8, 8, 8, 9
959 },
960 {
961 8, 8, 8, 8, 8, 8, 8, 8
962 }
963 },
964 {
965 {
966 0, 0, 0, 0, 0, 0, 0, 0
967 },
968 {
969 0, 0, 0, 0, 0, 0, 0, 1
970 },
971 {
972 0, 0, 0, 0, 0, 0, 1, 2
973 },
974 {
975 0, 0, 0, 0, 0, 1, 2, 3
976 },
977 {
978 0, 0, 0, 0, 1, 2, 3, 4
979 },
980 {
981 0, 0, 0, 1, 2, 3, 4, 5
982 },
983 {
984 0, 0, 1, 2, 3, 4, 5, 6
985 },
986 {
987 0, 1, 2, 3, 4, 5, 6, 7
988 },
989 {
990 1, 2, 3, 4, 5, 6, 7, 8
991 },
992 {
993 2, 3, 4, 5, 6, 7, 8, 8
994 },
995 {
996 3, 4, 5, 6, 7, 8, 8, 8
997 },
998 {
999 4, 5, 6, 7, 8, 8, 8, 8
1000 },
1001 {
1002 5, 6, 7, 8, 8, 8, 8, 8
1003 },
1004 {
1005 6, 7, 8, 8, 8, 8, 8, 8
1006 },
1007 {
1008 7, 8, 8, 8, 8, 8, 8, 8
1009 },
1010 {
1011 8, 8, 8, 8, 8, 8, 8, 8
1012 }
1013 },
1014 {
1015 {
1016 0, 0, 0, 0, 0, 0, 0, 0
1017 },
1018 {
1019 0, 0, 0, 0, 0, 0, 0, 15
1020 },
1021 {
1022 0, 0, 0, 0, 0, 0, 15, 14
1023 },
1024 {
1025 0, 0, 0, 0, 0, 15, 14, 13
1026 },
1027 {
1028 0, 0, 0, 0, 15, 14, 13, 12
1029 },
1030 {
1031 0, 0, 0, 15, 14, 13, 12, 11
1032 },
1033 {
1034 0, 0, 15, 14, 13, 12, 11, 10
1035 },
1036 {
1037 0, 15, 14, 13, 12, 11, 10, 9
1038 },
1039 {
1040 15, 14, 13, 12, 11, 10, 9, 8
1041 },
1042 {
1043 14, 13, 12, 11, 10, 9, 8, 8
1044 },
1045 {
1046 13, 12, 11, 10, 9, 8, 8, 8
1047 },
1048 {
1049 12, 11, 10, 9, 8, 8, 8, 8
1050 },
1051 {
1052 11, 10, 9, 8, 8, 8, 8, 8
1053 },
1054 {
1055 10, 9, 8, 8, 8, 8, 8, 8
1056 },
1057 {
1058 9, 8, 8, 8, 8, 8, 8, 8
1059 },
1060 {
1061 8, 8, 8, 8, 8, 8, 8, 8
1062 }
1063 }
1064 };
1065 */
1066
1067
1068
1069 /*
1070 for (int32_t blockrow=0; blockrow<30; ++i)
1071 {
1072 for (int32_t linerow=0; linerow<8; ++i)
1073 {
1074 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1075 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1076 {
1077 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1078 ++triangleline;
1079 }
1080 }
1081 }
1082 */
1083
1084 // the ULL suffixes are to prevent this warning:
1085 // warning: integer constant is too large for "int32_t" type
1086
1087 qword triangles[4][16][8]= //[direction][value][line]
1088 {
1089 {
1090 {
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL
1099 },
1100 {
1101 0xFD00000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL,
1107 0x0000000000000000ULL,
1108 0x0000000000000000ULL
1109 },
1110 {
1111 0xFDFD000000000000ULL,
1112 0xFD00000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL,
1117 0x0000000000000000ULL,
1118 0x0000000000000000ULL
1119 },
1120 {
1121 0xFDFDFD0000000000ULL,
1122 0xFDFD000000000000ULL,
1123 0xFD00000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL,
1128 0x0000000000000000ULL
1129 },
1130 {
1131 0xFDFDFDFD00000000ULL,
1132 0xFDFDFD0000000000ULL,
1133 0xFDFD000000000000ULL,
1134 0xFD00000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL,
1138 0x0000000000000000ULL
1139 },
1140 {
1141 0xFDFDFDFDFD000000ULL,
1142 0xFDFDFDFD00000000ULL,
1143 0xFDFDFD0000000000ULL,
1144 0xFDFD000000000000ULL,
1145 0xFD00000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL
1149 },
1150 {
1151 0xFDFDFDFDFDFD0000ULL,
1152 0xFDFDFDFDFD000000ULL,
1153 0xFDFDFDFD00000000ULL,
1154 0xFDFDFD0000000000ULL,
1155 0xFDFD000000000000ULL,
1156 0xFD00000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL
1159 },
1160 {
1161 0xFDFDFDFDFDFDFD00ULL,
1162 0xFDFDFDFDFDFD0000ULL,
1163 0xFDFDFDFDFD000000ULL,
1164 0xFDFDFDFD00000000ULL,
1165 0xFDFDFD0000000000ULL,
1166 0xFDFD000000000000ULL,
1167 0xFD00000000000000ULL,
1168 0x0000000000000000ULL
1169 },
1170 {
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFD00ULL,
1173 0xFDFDFDFDFDFD0000ULL,
1174 0xFDFDFDFDFD000000ULL,
1175 0xFDFDFDFD00000000ULL,
1176 0xFDFDFD0000000000ULL,
1177 0xFDFD000000000000ULL,
1178 0xFD00000000000000ULL
1179 },
1180 {
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFD00ULL,
1184 0xFDFDFDFDFDFD0000ULL,
1185 0xFDFDFDFDFD000000ULL,
1186 0xFDFDFDFD00000000ULL,
1187 0xFDFDFD0000000000ULL,
1188 0xFDFD000000000000ULL
1189 },
1190 {
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFD00ULL,
1195 0xFDFDFDFDFDFD0000ULL,
1196 0xFDFDFDFDFD000000ULL,
1197 0xFDFDFDFD00000000ULL,
1198 0xFDFDFD0000000000ULL
1199 },
1200 {
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFD00ULL,
1206 0xFDFDFDFDFDFD0000ULL,
1207 0xFDFDFDFDFD000000ULL,
1208 0xFDFDFDFD00000000ULL
1209 },
1210 {
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFD00ULL,
1217 0xFDFDFDFDFDFD0000ULL,
1218 0xFDFDFDFDFD000000ULL
1219 },
1220 {
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL,
1227 0xFDFDFDFDFDFDFD00ULL,
1228 0xFDFDFDFDFDFD0000ULL
1229 },
1230 {
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFDFDULL,
1236 0xFDFDFDFDFDFDFDFDULL,
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFD00ULL
1239 },
1240 {
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL
1249 }
1250 },
1251 {
1252 {
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL
1261 },
1262 {
1263 0x00000000000000FDULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL,
1269 0x0000000000000000ULL,
1270 0x0000000000000000ULL
1271 },
1272 {
1273 0x000000000000FDFDULL,
1274 0x00000000000000FDULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL,
1279 0x0000000000000000ULL,
1280 0x0000000000000000ULL
1281 },
1282 {
1283 0x0000000000FDFDFDULL,
1284 0x000000000000FDFDULL,
1285 0x00000000000000FDULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL,
1290 0x0000000000000000ULL
1291 },
1292 {
1293 0x00000000FDFDFDFDULL,
1294 0x0000000000FDFDFDULL,
1295 0x000000000000FDFDULL,
1296 0x00000000000000FDULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL,
1300 0x0000000000000000ULL
1301 },
1302 {
1303 0x000000FDFDFDFDFDULL,
1304 0x00000000FDFDFDFDULL,
1305 0x0000000000FDFDFDULL,
1306 0x000000000000FDFDULL,
1307 0x00000000000000FDULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL
1311 },
1312 {
1313 0x0000FDFDFDFDFDFDULL,
1314 0x000000FDFDFDFDFDULL,
1315 0x00000000FDFDFDFDULL,
1316 0x0000000000FDFDFDULL,
1317 0x000000000000FDFDULL,
1318 0x00000000000000FDULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL
1321 },
1322 {
1323 0x00FDFDFDFDFDFDFDULL,
1324 0x0000FDFDFDFDFDFDULL,
1325 0x000000FDFDFDFDFDULL,
1326 0x00000000FDFDFDFDULL,
1327 0x0000000000FDFDFDULL,
1328 0x000000000000FDFDULL,
1329 0x00000000000000FDULL,
1330 0x0000000000000000ULL
1331 },
1332 {
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0x00FDFDFDFDFDFDFDULL,
1335 0x0000FDFDFDFDFDFDULL,
1336 0x000000FDFDFDFDFDULL,
1337 0x00000000FDFDFDFDULL,
1338 0x0000000000FDFDFDULL,
1339 0x000000000000FDFDULL,
1340 0x00000000000000FDULL
1341 },
1342 {
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0x00FDFDFDFDFDFDFDULL,
1346 0x0000FDFDFDFDFDFDULL,
1347 0x000000FDFDFDFDFDULL,
1348 0x00000000FDFDFDFDULL,
1349 0x0000000000FDFDFDULL,
1350 0x000000000000FDFDULL
1351 },
1352 {
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0x00FDFDFDFDFDFDFDULL,
1357 0x0000FDFDFDFDFDFDULL,
1358 0x000000FDFDFDFDFDULL,
1359 0x00000000FDFDFDFDULL,
1360 0x0000000000FDFDFDULL
1361 },
1362 {
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0x00FDFDFDFDFDFDFDULL,
1368 0x0000FDFDFDFDFDFDULL,
1369 0x000000FDFDFDFDFDULL,
1370 0x00000000FDFDFDFDULL
1371 },
1372 {
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0x00FDFDFDFDFDFDFDULL,
1379 0x0000FDFDFDFDFDFDULL,
1380 0x000000FDFDFDFDFDULL
1381 },
1382 {
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL,
1389 0x00FDFDFDFDFDFDFDULL,
1390 0x0000FDFDFDFDFDFDULL
1391 },
1392 {
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0xFDFDFDFDFDFDFDFDULL,
1398 0xFDFDFDFDFDFDFDFDULL,
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0x00FDFDFDFDFDFDFDULL
1401 },
1402 {
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0xFDFDFDFDFDFDFDFDULL,
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL
1411 }
1412 },
1413 {
1414 {
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL
1423 },
1424 {
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0xFD00000000000000ULL
1433 },
1434 {
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0x0000000000000000ULL,
1440 0x0000000000000000ULL,
1441 0xFD00000000000000ULL,
1442 0xFDFD000000000000ULL
1443 },
1444 {
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0x0000000000000000ULL,
1450 0xFD00000000000000ULL,
1451 0xFDFD000000000000ULL,
1452 0xFDFDFD0000000000ULL
1453 },
1454 {
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0xFD00000000000000ULL,
1460 0xFDFD000000000000ULL,
1461 0xFDFDFD0000000000ULL,
1462 0xFDFDFDFD00000000ULL
1463 },
1464 {
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0x0000000000000000ULL,
1468 0xFD00000000000000ULL,
1469 0xFDFD000000000000ULL,
1470 0xFDFDFD0000000000ULL,
1471 0xFDFDFDFD00000000ULL,
1472 0xFDFDFDFDFD000000ULL
1473 },
1474 {
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0xFD00000000000000ULL,
1478 0xFDFD000000000000ULL,
1479 0xFDFDFD0000000000ULL,
1480 0xFDFDFDFD00000000ULL,
1481 0xFDFDFDFDFD000000ULL,
1482 0xFDFDFDFDFDFD0000ULL
1483 },
1484 {
1485 0x0000000000000000ULL,
1486 0xFD00000000000000ULL,
1487 0xFDFD000000000000ULL,
1488 0xFDFDFD0000000000ULL,
1489 0xFDFDFDFD00000000ULL,
1490 0xFDFDFDFDFD000000ULL,
1491 0xFDFDFDFDFDFD0000ULL,
1492 0xFDFDFDFDFDFDFD00ULL
1493 },
1494 {
1495 0xFD00000000000000ULL,
1496 0xFDFD000000000000ULL,
1497 0xFDFDFD0000000000ULL,
1498 0xFDFDFDFD00000000ULL,
1499 0xFDFDFDFDFD000000ULL,
1500 0xFDFDFDFDFDFD0000ULL,
1501 0xFDFDFDFDFDFDFD00ULL,
1502 0xFDFDFDFDFDFDFDFDULL
1503 },
1504 {
1505 0xFDFD000000000000ULL,
1506 0xFDFDFD0000000000ULL,
1507 0xFDFDFDFD00000000ULL,
1508 0xFDFDFDFDFD000000ULL,
1509 0xFDFDFDFDFDFD0000ULL,
1510 0xFDFDFDFDFDFDFD00ULL,
1511 0xFDFDFDFDFDFDFDFDULL,
1512 0xFDFDFDFDFDFDFDFDULL
1513 },
1514 {
1515 0xFDFDFD0000000000ULL,
1516 0xFDFDFDFD00000000ULL,
1517 0xFDFDFDFDFD000000ULL,
1518 0xFDFDFDFDFDFD0000ULL,
1519 0xFDFDFDFDFDFDFD00ULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL
1523 },
1524 {
1525 0xFDFDFDFD00000000ULL,
1526 0xFDFDFDFDFD000000ULL,
1527 0xFDFDFDFDFDFD0000ULL,
1528 0xFDFDFDFDFDFDFD00ULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL,
1532 0xFDFDFDFDFDFDFDFDULL
1533 },
1534 {
1535 0xFDFDFDFDFD000000ULL,
1536 0xFDFDFDFDFDFD0000ULL,
1537 0xFDFDFDFDFDFDFD00ULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL
1543 },
1544 {
1545 0xFDFDFDFDFDFD0000ULL,
1546 0xFDFDFDFDFDFDFD00ULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL,
1552 0xFDFDFDFDFDFDFDFDULL
1553 },
1554 {
1555 0xFDFDFDFDFDFDFD00ULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL
1563 },
1564 {
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL
1573 }
1574 },
1575 {
1576 {
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL
1585 },
1586 {
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL,
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x00000000000000FDULL
1595 },
1596 {
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x0000000000000000ULL,
1602 0x0000000000000000ULL,
1603 0x00000000000000FDULL,
1604 0x000000000000FDFDULL
1605 },
1606 {
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x0000000000000000ULL,
1612 0x00000000000000FDULL,
1613 0x000000000000FDFDULL,
1614 0x0000000000FDFDFDULL
1615 },
1616 {
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x00000000000000FDULL,
1622 0x000000000000FDFDULL,
1623 0x0000000000FDFDFDULL,
1624 0x00000000FDFDFDFDULL
1625 },
1626 {
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x0000000000000000ULL,
1630 0x00000000000000FDULL,
1631 0x000000000000FDFDULL,
1632 0x0000000000FDFDFDULL,
1633 0x00000000FDFDFDFDULL,
1634 0x000000FDFDFDFDFDULL
1635 },
1636 {
1637 0x0000000000000000ULL,
1638 0x0000000000000000ULL,
1639 0x00000000000000FDULL,
1640 0x000000000000FDFDULL,
1641 0x0000000000FDFDFDULL,
1642 0x00000000FDFDFDFDULL,
1643 0x000000FDFDFDFDFDULL,
1644 0x0000FDFDFDFDFDFDULL
1645 },
1646 {
1647 0x0000000000000000ULL,
1648 0x00000000000000FDULL,
1649 0x000000000000FDFDULL,
1650 0x0000000000FDFDFDULL,
1651 0x00000000FDFDFDFDULL,
1652 0x000000FDFDFDFDFDULL,
1653 0x0000FDFDFDFDFDFDULL,
1654 0x00FDFDFDFDFDFDFDULL
1655 },
1656 {
1657 0x00000000000000FDULL,
1658 0x000000000000FDFDULL,
1659 0x0000000000FDFDFDULL,
1660 0x00000000FDFDFDFDULL,
1661 0x000000FDFDFDFDFDULL,
1662 0x0000FDFDFDFDFDFDULL,
1663 0x00FDFDFDFDFDFDFDULL,
1664 0xFDFDFDFDFDFDFDFDULL
1665 },
1666 {
1667 0x000000000000FDFDULL,
1668 0x0000000000FDFDFDULL,
1669 0x00000000FDFDFDFDULL,
1670 0x000000FDFDFDFDFDULL,
1671 0x0000FDFDFDFDFDFDULL,
1672 0x00FDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL
1675 },
1676 {
1677 0x0000000000FDFDFDULL,
1678 0x00000000FDFDFDFDULL,
1679 0x000000FDFDFDFDFDULL,
1680 0x0000FDFDFDFDFDFDULL,
1681 0x00FDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL
1685 },
1686 {
1687 0x00000000FDFDFDFDULL,
1688 0x000000FDFDFDFDFDULL,
1689 0x0000FDFDFDFDFDFDULL,
1690 0x00FDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL
1695 },
1696 {
1697 0x000000FDFDFDFDFDULL,
1698 0x0000FDFDFDFDFDFDULL,
1699 0x00FDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL
1705 },
1706 {
1707 0x0000FDFDFDFDFDFDULL,
1708 0x00FDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL
1715 },
1716 {
1717 0x00FDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL
1725 },
1726 {
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL
1735 }
1736 }
1737 };
1738
1739 int32_t black_opening_count=0;
1740 int32_t black_opening_x,black_opening_y;
1741 int32_t black_opening_shape;
1742
1743 1507 int32_t choose_opening_shape()
1744 {
1745 // First, count how many bits are set
1746 1507 int32_t numBits=0;
1747 int32_t bitCounter;
1748
1749
2/2
✓ Branch 0 taken 7535 times.
✓ Branch 1 taken 1507 times.
9042 for(int32_t i=0; i<bosMAX; i++)
1750 {
1751
2/2
✓ Branch 0 taken 5812 times.
✓ Branch 1 taken 1723 times.
7535 if(COOLSCROLL&(1<<i))
1752 1723 numBits++;
1753 7535 }
1754
1755 // Shouldn't happen...
1756
1/2
✓ Branch 0 taken 1507 times.
✗ Branch 1 not taken.
1507 if(numBits==0)
1757 return bosCIRCLE;
1758
1759 // Pick a bit
1760 1507 bitCounter=zc_rand()%numBits+1;
1761
1762
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 26 times.
2018 for(int32_t i=0; i<bosMAX; i++)
1763 {
1764 // If this bit is set, decrement the bit counter
1765
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1637 times.
1992 if(COOLSCROLL&(1<<i))
1766 1637 bitCounter--;
1767
1768 // When the counter hits 0, return a value based on
1769 // which bit it stopped on.
1770 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1771
2/2
✓ Branch 0 taken 1481 times.
✓ Branch 1 taken 511 times.
1992 if(bitCounter==0)
1772 1481 return i;
1773 511 }
1774
1775 // Shouldn't be necessary, but the compiler might complain, at least
1776 26 return bosCIRCLE;
1777 1507 }
1778
1779 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1780 {
1781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1782
1783 396 int32_t w=256, h=224;
1784 396 int32_t blockrows=28, blockcolumns=32;
1785 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1786
1787
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1788 {
1789
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1790 {
1791
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1792 354816 }
1793 11088 }
1794
1795 396 black_opening_count = 66;
1796 396 black_opening_x = x;
1797 396 black_opening_y = y;
1798 396 lensclk = 0;
1799 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1800
1801
1802
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1803 {
1804 refreshTints();
1805 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1806 }
1807
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1808 {
1809 FFCore.warpScriptCheck();
1810 for(int32_t i=0; i<66; i++)
1811 {
1812 draw_screen(tmpscr);
1813 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1814 advanceframe(true);
1815
1816 if(Quit)
1817 {
1818 break;
1819 }
1820 }
1821 }
1822 396 }
1823
1824 1111 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1825 {
1826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111 times.
1111 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1827
1828 1111 int32_t w=256, h=224;
1829 1111 int32_t blockrows=28, blockcolumns=32;
1830 1111 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1831
1832
2/2
✓ Branch 0 taken 31108 times.
✓ Branch 1 taken 1111 times.
32219 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1833 {
1834
2/2
✓ Branch 0 taken 995456 times.
✓ Branch 1 taken 31108 times.
1026564 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1835 {
1836
2/2
✓ Branch 0 taken 442711 times.
✓ Branch 1 taken 552745 times.
995456 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1837 995456 }
1838 31108 }
1839
1840 1111 black_opening_count = -66;
1841 1111 black_opening_x = x;
1842 1111 black_opening_y = y;
1843 1111 lensclk = 0;
1844
1/2
✓ Branch 0 taken 1111 times.
✗ Branch 1 not taken.
1111 if(black_opening_shape == bosFADEBLACK)
1845 {
1846 refreshTints();
1847 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1848 }
1849
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 912 times.
1111 if(wait)
1850 {
1851 912 FFCore.warpScriptCheck();
1852
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 60192 times.
61104 for(int32_t i=0; i<66; i++)
1853 {
1854 60192 draw_screen(tmpscr);
1855 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1856 60192 advanceframe(true);
1857
1858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60192 times.
60192 if(Quit)
1859 {
1860 break;
1861 }
1862 60192 }
1863 912 }
1864 1111 }
1865
1866 99462 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1867 {
1868 99462 clear_to_color(tmp_scr,BLACK);
1869 99462 int32_t w=256, h=224;
1870
1871
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90288 times.
99462 switch(black_opening_shape)
1872 {
1873 case bosOVAL:
1874 {
1875 858 double new_w=(w/2)+abs(w/2-x);
1876 858 double new_h=(h/2)+abs(h/2-y);
1877 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1878 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1879 858 break;
1880 }
1881
1882 case bosTRIANGLE:
1883 {
1884 660 double new_w=(w/2)+abs(w/2-x);
1885 660 double new_h=(h/2)+abs(h/2-y);
1886 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1887 660 double P2= (PI/2);
1888 660 double P23=(2*PI/3);
1889 660 double P43=(4*PI/3);
1890 660 double Pa= (-4*PI*a/(3*max_a));
1891 660 double angle=P2+Pa;
1892 660 double a0=angle;
1893 660 double a2=angle+P23;
1894 660 double a4=angle+P43;
1895 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1896 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1897 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1898 0);
1899 660 break;
1900 }
1901
1902 case bosSMAS:
1903 {
1904
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1905
1906
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1907 {
1908
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1909 {
1910 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1911
1912
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1913 {
1914 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1915
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1916 54878208 [linerow];
1917 54878208 ++triangleline;
1918
1919
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1920 {
1921 6859776 }
1922 54878208 }
1923 1714944 }
1924 214368 }
1925
1926 7656 break;
1927 }
1928
1929 case bosFADEBLACK:
1930 {
1931 if(black_opening_count<0)
1932 {
1933 black_fade(zc_min(-black_opening_count,63));
1934 }
1935 else if(black_opening_count>0)
1936 {
1937 black_fade(63-zc_max(black_opening_count-3,0));
1938 }
1939 else black_fade(0);
1940 return; //no blitting from tmp_scr!
1941 }
1942
1943 90288 case bosCIRCLE:
1944 default:
1945 {
1946 90288 double new_w=(w/2)+abs(w/2-x);
1947 90288 double new_h=(h/2)+abs(h/2-y);
1948 90288 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1949 //circlefill(tmp_scr,x,y,a<<3,0);
1950 90288 circlefill(tmp_scr,x,y,r,0);
1951 90288 break;
1952 }
1953 }
1954
1955 99462 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1956 99462 }
1957
1958
1959 void black_fade(int32_t fadeamnt)
1960 {
1961 for(int32_t i=0; i < 0xEF; i++)
1962 {
1963 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1964 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1965 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1966 }
1967
1968 refreshpal = true;
1969 }
1970
1971 //----------------------------------------------------------------
1972
1973 44453039 bool item_disabled(int32_t item) //is this item disabled?
1974 {
1975
2/2
✓ Branch 0 taken 1796436 times.
✓ Branch 1 taken 42656603 times.
44453039 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1976 }
1977
1978 7617843 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1979 {
1980
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7482595 times.
7617843 if(current_item(item_type, true) >=item)
1981 {
1982 135248 return true;
1983 }
1984
1985 7482595 return false;
1986 7617843 }
1987
1988 31051977 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1989 {
1990
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16169148 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31051977 switch(item_type)
1991 {
1992 case itype_bomb:
1993 case itype_sbomb:
1994 {
1995 int32_t itemid = getItemID(itemsbuf, item_type, it);
1996
1997 if(itemid == -1)
1998 return false;
1999
2000 return (game->get_item(itemid));
2001 }
2002
2003 case itype_clock:
2004 {
2005 6053367 int32_t itemid = getItemID(itemsbuf, item_type, it);
2006
2007
2/4
✓ Branch 0 taken 6053367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6053367 times.
✗ Branch 3 not taken.
6053367 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2008 return (game->get_item(itemid));
2009 6053367 return Hero.getClock()?1:0;
2010 }
2011
2012 case itype_key:
2013 return (game->get_keys()>0);
2014
2015 case itype_magiccontainer:
2016 return (game->get_maxmagic()>=game->get_mp_per_block());
2017
2018 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2019 {
2020
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2021 {
2022 case -2:
2023 {
2024 for(int32_t i=0; i<MAXLEVELS; i++)
2025 {
2026 if(game->lvlitems[i]&liTRIFORCE)
2027 {
2028 return true;
2029 }
2030 }
2031
2032 return false;
2033 }
2034
2035 case -1:
2036 return (game->lvlitems[dlevel]&liTRIFORCE);
2037
2038 default:
2039
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2040 {
2041 3220277 return (game->lvlitems[it]&liTRIFORCE);
2042 }
2043
2044 break;
2045 }
2046
2047 return 0;
2048 }
2049
2050 case itype_map: //it: -2=any, -1=current level, other=that level
2051 {
2052
1/3
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16169148 switch(it)
2053 {
2054 case -2:
2055 {
2056 for(int32_t i=0; i<MAXLEVELS; i++)
2057 {
2058 if(game->lvlitems[i]&liMAP)
2059 {
2060 return true;
2061 }
2062 }
2063
2064 return false;
2065 }
2066
2067 case -1:
2068 return (game->lvlitems[dlevel]&liMAP)!=0;
2069
2070 default:
2071
2/4
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16169148 times.
16169148 if(it>=0&&it<MAXLEVELS)
2072 {
2073 16169148 return (game->lvlitems[it]&liMAP)!=0;
2074 }
2075
2076 break;
2077 }
2078
2079 return 0;
2080 }
2081
2082 case itype_compass: //it: -2=any, -1=current level, other=that level
2083 {
2084
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2085 {
2086 case -2:
2087 {
2088 for(int32_t i=0; i<MAXLEVELS; i++)
2089 {
2090 if(game->lvlitems[i]&liCOMPASS)
2091 {
2092 return true;
2093 }
2094 }
2095
2096 return false;
2097 }
2098
2099 case -1:
2100 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2101
2102 default:
2103
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2104 {
2105 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2106 }
2107
2108 break;
2109 }
2110 return 0;
2111 }
2112
2113 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2114 {
2115
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2116 {
2117 case -2:
2118 {
2119 for(int32_t i=0; i<MAXLEVELS; i++)
2120 {
2121 if(game->lvlitems[i]&liBOSSKEY)
2122 {
2123 return true;
2124 }
2125 }
2126
2127 return false;
2128 }
2129
2130 case -1:
2131 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2132
2133 default:
2134
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2135 {
2136 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2137 }
2138 break;
2139 }
2140 return 0;
2141 }
2142
2143 default:
2144 //it=(1<<(it-1));
2145 /*if (item_type>=itype_max)
2146 {
2147 enter_sys_pal();
2148 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2149 exit_sys_pal();
2150
2151 return false;
2152 }*/
2153 int32_t itemid = getItemID(itemsbuf, item_type, it);
2154
2155 if(itemid == -1)
2156 return false;
2157
2158 return game->get_item(itemid);
2159 }
2160 31051977 }
2161
2162
2163 100011978 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2164 {
2165
9/9
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 51585042 times.
✓ Branch 2 taken 6053367 times.
✓ Branch 3 taken 6053367 times.
✓ Branch 4 taken 6053367 times.
✓ Branch 5 taken 6053367 times.
✓ Branch 6 taken 6053367 times.
✓ Branch 7 taken 6053367 times.
✓ Branch 8 taken 6053367 times.
100011978 switch(item_type)
2166 {
2167 case itype_clock:
2168 {
2169 6053367 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2170
2171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6053367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6053367 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2172 return itemsbuf[maxid].fam_type;
2173
2174 6053367 return has_item(itype_clock,1) ? 1 : 0;
2175 }
2176
2177 case itype_key:
2178 6053367 return game->get_keys();
2179
2180 case itype_lkey:
2181 6053367 return game->lvlkeys[get_dlevel()];
2182
2183 case itype_magiccontainer:
2184 6053367 return game->get_maxmagic()/game->get_mp_per_block();
2185
2186 case itype_triforcepiece:
2187 {
2188 6053367 int32_t count=0;
2189
2190
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2191 {
2192 3099323904 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2193 3099323904 }
2194
2195 6053367 return count;
2196 }
2197
2198 case itype_map:
2199 {
2200 6053367 int32_t count=0;
2201
2202
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2203 {
2204 3099323904 count+=(game->lvlitems[i]&liMAP)?1:0;
2205 3099323904 }
2206
2207 6053367 return count;
2208 }
2209
2210 case itype_compass:
2211 {
2212 6053367 int32_t count=0;
2213
2214
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2215 {
2216 3099323904 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2217 3099323904 }
2218
2219 6053367 return count;
2220 }
2221
2222 case itype_bosskey:
2223 {
2224 6053367 int32_t count=0;
2225
2226
2/2
✓ Branch 0 taken 3099323904 times.
✓ Branch 1 taken 6053367 times.
3105377271 for(int32_t i=0; i<MAXLEVELS; i++)
2227 {
2228 3099323904 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2229 3099323904 }
2230
2231 6053367 return count;
2232 }
2233
2234 default:
2235 51585042 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2236
2237
2/2
✓ Branch 0 taken 9873870 times.
✓ Branch 1 taken 41711172 times.
51585042 if(maxid == -1)
2238 41711172 return 0;
2239
2240 9873870 return itemsbuf[maxid].fam_type;
2241 }
2242 100011978 }
2243
2244 92394135 int32_t current_item(int32_t item_type) //item currently being used
2245 {
2246 92394135 return current_item(item_type, true);
2247 }
2248
2249 116 std::map<int32_t, int32_t> itemcache;
2250 116 std::map<int32_t, int32_t> itemcache_cost;
2251
2252 void removeFromItemCache(int32_t itemclass)
2253 {
2254 itemcache.erase(itemclass);
2255 itemcache_cost.erase(itemclass);
2256 }
2257
2258 5857125 void flushItemCache(bool justcost)
2259 {
2260 5857125 itemcache_cost.clear();
2261
2/2
✓ Branch 0 taken 5827094 times.
✓ Branch 1 taken 30031 times.
5857125 if(!justcost)
2262 30031 itemcache.clear();
2263
2/2
✓ Branch 0 taken 5826995 times.
✓ Branch 1 taken 99 times.
5827094 else if(replay_version_check(0,19))
2264 5826995 return;
2265
2266 //also fix the active subscreen if items were deleted -DD
2267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30130 times.
30130 if(game != NULL)
2268 {
2269 30130 verifyBothWeapons();
2270 30130 refresh_subscr_items();
2271 30130 }
2272 5857125 }
2273
2274 // This is used often, so it should be as direct as possible.
2275 3376276306 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2276 {
2277 3376276306 bool use_cost_cache = replay_version_check(19);
2278
2/2
✓ Branch 0 taken 3300716816 times.
✓ Branch 1 taken 75559490 times.
3376276306 if(jinx_check)
2279 {
2280
4/4
✓ Branch 0 taken 47353141 times.
✓ Branch 1 taken 28206349 times.
✓ Branch 2 taken 8273869 times.
✓ Branch 3 taken 39079272 times.
75559490 if(!(HeroSwordClk() || HeroItemClk()))
2281 39079272 jinx_check = false; //not jinxed
2282 75559490 }
2283
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3375228860 times.
3376276306 if(!Hero.BunnyClock())
2284 3375228860 check_bunny = false; //not bunnied
2285
2/2
✓ Branch 0 taken 3346669576 times.
✓ Branch 1 taken 29606730 times.
3376276306 if(itemtype == itype_ring) checkmagic = true;
2286
4/4
✓ Branch 0 taken 3339796088 times.
✓ Branch 1 taken 36480218 times.
✓ Branch 2 taken 3308450265 times.
✓ Branch 3 taken 29257707 times.
6713984278 if (!jinx_check && !check_bunny
2287
3/4
✓ Branch 0 taken 3339796088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337707972 times.
✓ Branch 3 taken 2088116 times.
3339796088 && (use_cost_cache || itemtype != itype_ring))
2288 {
2289
4/4
✓ Branch 0 taken 185317066 times.
✓ Branch 1 taken 3125221315 times.
✓ Branch 2 taken 185130755 times.
✓ Branch 3 taken 186311 times.
3310538381 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2290 3310538381 auto res = cache.find(itemtype);
2291
2292
2/2
✓ Branch 0 taken 3295212171 times.
✓ Branch 1 taken 15326210 times.
3310538381 if(res != cache.end())
2293 3295212171 return res->second;
2294 15326210 }
2295
2296 81064135 int32_t result = -1;
2297 81064135 int32_t highestlevel = -1;
2298
2299
2/2
✓ Branch 0 taken 20752418560 times.
✓ Branch 1 taken 81064135 times.
20833482695 for(int32_t i=0; i<MAXITEMS; i++)
2300 {
2301
5/6
✓ Branch 0 taken 1522409302 times.
✓ Branch 1 taken 19230009258 times.
✓ Branch 2 taken 21890842 times.
✓ Branch 3 taken 1500518460 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21890842 times.
20752418560 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2302 {
2303
4/4
✓ Branch 0 taken 20046815 times.
✓ Branch 1 taken 1844027 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20038121 times.
21890842 if(checkmagic && itemtype != itype_magicring)
2304
2/2
✓ Branch 0 taken 20037951 times.
✓ Branch 1 taken 170 times.
20038121 if(!checkmagiccost(i))
2305 170 continue;
2306
6/6
✓ Branch 0 taken 18598411 times.
✓ Branch 1 taken 3292261 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049225 times.
✓ Branch 4 taken 1846135 times.
✓ Branch 5 taken 1446126 times.
21890672 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446126 times.
1446126 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2308 1446126 continue;
2309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20444546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20444546 if(check_bunny && !checkbunny(i))
2310 continue;
2311
2312
2/2
✓ Branch 0 taken 280132 times.
✓ Branch 1 taken 20164414 times.
20444546 if(itemsbuf[i].fam_type >= highestlevel)
2313 {
2314 20164414 highestlevel = itemsbuf[i].fam_type;
2315 20164414 result=i;
2316 20164414 }
2317 20444546 }
2318 20750972264 }
2319
2320
3/4
✓ Branch 0 taken 44583917 times.
✓ Branch 1 taken 36480218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44583917 times.
81064135 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2321 {
2322
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 44581403 times.
44583917 if (use_cost_cache)
2323 {
2324
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 1620 times.
2514 if (!checkmagic)
2325 1620 itemcache[itemtype] = result;
2326
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
2514 if (checkmagic || result < 0 || checkmagiccost(result))
2327 2514 itemcache_cost[itemtype] = result;
2328 2514 }
2329 else
2330 {
2331 44581403 itemcache[itemtype] = result;
2332 }
2333 44583917 }
2334 81064135 return result;
2335 3376276306 }
2336
2337 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2338 3340240301 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2339 {
2340
2/4
✓ Branch 0 taken 3340240301 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3340240301 times.
3340240301 if(itype < 0 || itype >= itype_max) return -1;
2341
1/2
✓ Branch 0 taken 3340240301 times.
✗ Branch 1 not taken.
3340240301 if(game->OverrideItems[itype] > -2)
2342 {
2343 auto ovid = game->OverrideItems[itype];
2344 if(ovid < 0 || ovid >= MAXITEMS)
2345 return -1;
2346 if(itemsbuf[ovid].family == itype)
2347 {
2348 if(itype == itype_magicring)
2349 checkmagic = false;
2350 else if(itype == itype_ring)
2351 checkmagic = true;
2352
2353 if(checkmagic && !checkmagiccost(ovid))
2354 return -1;
2355 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2356 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2357 return -1;
2358 return ovid;
2359 }
2360 }
2361 3340240301 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2362
2/2
✓ Branch 0 taken 39523485 times.
✓ Branch 1 taken 3300716816 times.
3340240301 if(!jinx_check) //If not already a jinx-immune-only check...
2363 {
2364 //And the player IS jinxed...
2365
4/4
✓ Branch 0 taken 3272853444 times.
✓ Branch 1 taken 27863372 times.
✓ Branch 2 taken 8172633 times.
✓ Branch 3 taken 3264680811 times.
3300716816 if(HeroSwordClk() || HeroItemClk())
2366 {
2367 //Then do a jinx-immune-only check here
2368 36036005 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2369 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2370 //Should NOT need a compat rule, as this should always return -1 in old quests.
2371
2/2
✓ Branch 0 taken 1261310 times.
✓ Branch 1 taken 34774695 times.
36036005 if(ret2 > -1) return ret2;
2372 34774695 }
2373 3299455506 }
2374 3338978991 return ret;
2375 3340240301 }
2376
2377 19333396 int32_t current_item_power(int32_t itemtype)
2378 {
2379 19333396 int32_t result = current_item_id(itemtype,true);
2380
2/2
✓ Branch 0 taken 14040642 times.
✓ Branch 1 taken 5292754 times.
19333396 return (result<0) ? 0 : itemsbuf[result].power;
2381 }
2382
2383 11 int32_t heart_container_id()
2384 {
2385
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2386 {
2387
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2388 {
2389 11 return i;
2390 }
2391 308 }
2392 return -1;
2393 11 }
2394
2395 6053367 int32_t item_tile_mod()
2396 {
2397 6053367 int32_t tile=0;
2398
2399
2/2
✓ Branch 0 taken 1206356 times.
✓ Branch 1 taken 4847011 times.
6053367 if(game->get_bombs())
2400 {
2401 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2402
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2403 4681842 tile+=itemsbuf[itemid].ltm;
2404 4847011 }
2405
2406
2/2
✓ Branch 0 taken 4539291 times.
✓ Branch 1 taken 1514076 times.
6053367 if(game->get_sbombs())
2407 {
2408 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2409
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2410 1512648 tile+=itemsbuf[itemid].ltm;
2411 1514076 }
2412
2413
2/2
✓ Branch 0 taken 5943667 times.
✓ Branch 1 taken 109700 times.
6053367 if(current_item(itype_clock))
2414 {
2415 109700 int32_t itemid =
2416
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2417 ? iClock
2418 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2419
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2420 109700 tile+=itemsbuf[itemid].ltm;
2421 109700 }
2422
2423
2/2
✓ Branch 0 taken 4672626 times.
✓ Branch 1 taken 1380741 times.
6053367 if(current_item(itype_key))
2424 {
2425 1380741 int32_t itemid =
2426
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2427 ? iKey
2428 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2429
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2430 1380741 tile+=itemsbuf[itemid].ltm;
2431 1380741 }
2432
2433
2/2
✓ Branch 0 taken 5786264 times.
✓ Branch 1 taken 267103 times.
6053367 if(current_item(itype_lkey))
2434 {
2435 267103 int32_t itemid =
2436
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2437 ? iLevelKey
2438 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2439
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2440 267103 tile+=itemsbuf[itemid].ltm;
2441 267103 }
2442
2443
2/2
✓ Branch 0 taken 1256550 times.
✓ Branch 1 taken 4796817 times.
6053367 if(current_item(itype_map))
2444 {
2445 4796817 int32_t itemid =
2446
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2447 ? iMap
2448 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2449
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2450 4796817 tile+=itemsbuf[itemid].ltm;
2451 4796817 }
2452
2453
2/2
✓ Branch 0 taken 1234668 times.
✓ Branch 1 taken 4818699 times.
6053367 if(current_item(itype_compass))
2454 {
2455 4818699 int32_t itemid =
2456
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2457 ? iCompass
2458 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2459
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2460 4818699 tile+=itemsbuf[itemid].ltm;
2461 4818699 }
2462
2463
2/2
✓ Branch 0 taken 3422822 times.
✓ Branch 1 taken 2630545 times.
6053367 if(current_item(itype_bosskey))
2464 {
2465 2630545 int32_t itemid =
2466
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2467 ? iBossKey
2468 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2469
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2470 2630545 tile+=itemsbuf[itemid].ltm;
2471 2630545 }
2472
2473
2/2
✓ Branch 0 taken 2919391 times.
✓ Branch 1 taken 3133976 times.
6053367 if(current_item(itype_magiccontainer))
2474 {
2475 3133976 int32_t itemid =
2476
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2477 ? iMagicC
2478 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2479
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2480 3132106 tile+=itemsbuf[itemid].ltm;
2481 3133976 }
2482
2483
2/2
✓ Branch 0 taken 1592733 times.
✓ Branch 1 taken 4460634 times.
6053367 if(current_item(itype_triforcepiece))
2484 {
2485 4460634 int32_t itemid =
2486
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2487 ? iTriforce
2488 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2489
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2490 4460634 tile+=itemsbuf[itemid].ltm;
2491 4460634 }
2492
2493
2/2
✓ Branch 0 taken 6053367 times.
✓ Branch 1 taken 3099323904 times.
3105377271 for(int32_t i=0; i<itype_max; i++)
2494 {
2495
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56872448 times.
3099323904 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2496 {
2497
2/2
✓ Branch 0 taken 1110790 times.
✓ Branch 1 taken 55761658 times.
56872448 switch(i)
2498 {
2499 case itype_bomb:
2500 case itype_sbomb:
2501 case itype_clock:
2502 case itype_key:
2503 case itype_lkey:
2504 case itype_map:
2505 case itype_compass:
2506 case itype_bosskey:
2507 case itype_magiccontainer:
2508 case itype_triforcepiece:
2509 1110790 continue; //already handled
2510 }
2511 55761658 }
2512 3098213114 int32_t itemid = current_item_id(i,false);
2513
2/2
✓ Branch 0 taken 3092159747 times.
✓ Branch 1 taken 6053367 times.
3098213114 if(i == itype_shield)
2514 6053367 itemid = getCurrentShield(false);
2515
2516
4/4
✓ Branch 0 taken 80855172 times.
✓ Branch 1 taken 3017357942 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80754191 times.
3098213114 if(itemid < 0 || !checkbunny(itemid))
2517 3017458923 continue;
2518
2519 80754191 itemdata const& itm = itemsbuf[itemid];
2520
2521
2/2
✓ Branch 0 taken 75338158 times.
✓ Branch 1 taken 5416033 times.
80754191 switch(itm.family)
2522 {
2523 case itype_shield:
2524
1/2
✓ Branch 0 taken 5416033 times.
✗ Branch 1 not taken.
5416033 if(itm.flags & ITEM_FLAG9) //active shield
2525 {
2526 if(!usingActiveShield(itemid))
2527 {
2528 tile+=itm.misc6; //'Inactive PTM'
2529 continue;
2530 }
2531 }
2532 5416033 break;
2533 }
2534
2535 80754191 tile+=itm.ltm;
2536 80754191 }
2537
2538 6053367 return tile;
2539 }
2540
2541 6053367 int32_t bunny_tile_mod()
2542 {
2543
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6051497 times.
6053367 if(Hero.BunnyClock())
2544 {
2545 1870 return game->get_bunny_ltm();
2546 }
2547 6051497 return 0;
2548 6053367 }
2549
2550 // Hints are drawn on a separate layer to combo reveals.
2551 16332 void draw_lens_under(BITMAP *dest, bool layer)
2552 {
2553 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2554 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2555 //Lens flag 3: Don't show armos/chest/dive items
2556 //Lens flag 4: Show Raft Paths
2557 //Lens flag 5: Show Invisible Enemies
2558
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2559
2560 16332 int32_t strike_hint_table[11]=
2561 {
2562 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2563 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2564 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2565 };
2566
2567 // int32_t page = tmpscr->cpage;
2568 {
2569 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2570 // int32_t temptimer=0;
2571 16332 int32_t tempitem, tempweapon=0;
2572 16332 strike_hint=strike_hint_table[strike_hint_counter];
2573
2574
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2575 {
2576 490 strike_hint_timer=0;
2577 490 strike_hint_counter=((strike_hint_counter+1)%11);
2578 490 }
2579
2580 16332 ++strike_hint_timer;
2581
2582
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2583 {
2584 2874432 int32_t x = (i & 15) << 4;
2585 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2586 2874432 int32_t tempitemx=-16, tempitemy=-16;
2587 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2588
2589
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2590 {
2591 5748864 int32_t checkflag=0;
2592
2593
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2594 {
2595 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2596 2874432 }
2597 else
2598 {
2599 2874432 checkflag=tmpscr->sflag[i];
2600 }
2601
2602
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2603 {
2604
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2605 {
2606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2607 906 }
2608 else
2609 {
2610 192 checkflag = strike_hint;
2611 }
2612 1098 }
2613
2614
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2615 {
2616 case 0:
2617 case mfZELDA:
2618 case mfPUSHED:
2619 case mfENEMY0:
2620 case mfENEMY1:
2621 case mfENEMY2:
2622 case mfENEMY3:
2623 case mfENEMY4:
2624 case mfENEMY5:
2625 case mfENEMY6:
2626 case mfENEMY7:
2627 case mfENEMY8:
2628 case mfENEMY9:
2629 case mfSINGLE:
2630 case mfSINGLE16:
2631 case mfNOENEMY:
2632 case mfTRAP_H:
2633 case mfTRAP_V:
2634 case mfTRAP_4:
2635 case mfTRAP_LR:
2636 case mfTRAP_UD:
2637 case mfNOGROUNDENEMY:
2638 case mfNOBLOCKS:
2639 case mfSCRIPT1:
2640 case mfSCRIPT2:
2641 case mfSCRIPT3:
2642 case mfSCRIPT4:
2643 case mfSCRIPT5:
2644 case mfSCRIPT6:
2645 case mfSCRIPT7:
2646 case mfSCRIPT8:
2647 case mfSCRIPT9:
2648 case mfSCRIPT10:
2649 case mfSCRIPT11:
2650 case mfSCRIPT12:
2651 case mfSCRIPT13:
2652 case mfSCRIPT14:
2653 case mfSCRIPT15:
2654 case mfSCRIPT16:
2655 case mfSCRIPT17:
2656 case mfSCRIPT18:
2657 case mfSCRIPT19:
2658 case mfSCRIPT20:
2659 case mfPITHOLE:
2660 case mfPITFALLFLOOR:
2661 case mfLAVA:
2662 case mfICE:
2663 case mfICEDAMAGE:
2664 case mfDAMAGE1:
2665 case mfDAMAGE2:
2666 case mfDAMAGE4:
2667 case mfDAMAGE8:
2668 case mfDAMAGE16:
2669 case mfDAMAGE32:
2670 case mfFREEZEALL:
2671 case mfFREZEALLANSFFCS:
2672 case mfFREEZEFFCSOLY:
2673 case mfSCRITPTW1TRIG:
2674 case mfSCRITPTW2TRIG:
2675 case mfSCRITPTW3TRIG:
2676 case mfSCRITPTW4TRIG:
2677 case mfSCRITPTW5TRIG:
2678 case mfSCRITPTW6TRIG:
2679 case mfSCRITPTW7TRIG:
2680 case mfSCRITPTW8TRIG:
2681 case mfSCRITPTW9TRIG:
2682 case mfSCRITPTW10TRIG:
2683 case mfTROWEL:
2684 case mfTROWELNEXT:
2685 case mfTROWELSPECIALITEM:
2686 case mfSLASHPOT:
2687 case mfLIFTPOT:
2688 case mfLIFTORSLASH:
2689 case mfLIFTROCK:
2690 case mfLIFTROCKHEAVY:
2691 case mfDROPITEM:
2692 case mfSPECIALITEM:
2693 case mfDROPKEY:
2694 case mfDROPLKEY:
2695 case mfDROPCOMPASS:
2696 case mfDROPMAP:
2697 case mfDROPBOSSKEY:
2698 case mfSPAWNNPC:
2699 case mfSWITCHHOOK:
2700 case mfSIDEVIEWLADDER:
2701 case mfSIDEVIEWPLATFORM:
2702 case mfNOENEMYSPAWN:
2703 case mfENEMYALL:
2704 case mfNOMIRROR:
2705 case mfUNSAFEGROUND:
2706 case mf168:
2707 case mf169:
2708 case mf170:
2709 case mf171:
2710 case mf172:
2711 case mf173:
2712 case mf174:
2713 case mf175:
2714 case mf176:
2715 case mf177:
2716 case mf178:
2717 case mf179:
2718 case mf180:
2719 case mf181:
2720 case mf182:
2721 case mf183:
2722 case mf184:
2723 case mf185:
2724 case mf186:
2725 case mf187:
2726 case mf188:
2727 case mf189:
2728 case mf190:
2729 case mf191:
2730 case mf192:
2731 case mf193:
2732 case mf194:
2733 case mf195:
2734 case mf196:
2735 case mf197:
2736 case mf198:
2737 case mf199:
2738 case mf200:
2739 case mf201:
2740 case mf202:
2741 case mf203:
2742 case mf204:
2743 case mf205:
2744 case mf206:
2745 case mf207:
2746 case mf208:
2747 case mf209:
2748 case mf210:
2749 case mf211:
2750 case mf212:
2751 case mf213:
2752 case mf214:
2753 case mf215:
2754 case mf216:
2755 case mf217:
2756 case mf218:
2757 case mf219:
2758 case mf220:
2759 case mf221:
2760 case mf222:
2761 case mf223:
2762 case mf224:
2763 case mf225:
2764 case mf226:
2765 case mf227:
2766 case mf228:
2767 case mf229:
2768 case mf230:
2769 case mf231:
2770 case mf232:
2771 case mf233:
2772 case mf234:
2773 case mf235:
2774 case mf236:
2775 case mf237:
2776 case mf238:
2777 case mf239:
2778 case mf240:
2779 case mf241:
2780 case mf242:
2781 case mf243:
2782 case mf244:
2783 case mf245:
2784 case mf246:
2785 case mf247:
2786 case mf248:
2787 case mf249:
2788 case mf250:
2789 case mf251:
2790 case mf252:
2791 case mf253:
2792 case mf254:
2793 case mfEXTENDED:
2794 5706470 break;
2795
2796 case mfPUSHUD:
2797 case mfPUSHLR:
2798 case mfPUSH4:
2799 case mfPUSHU:
2800 case mfPUSHD:
2801 case mfPUSHL:
2802 case mfPUSHR:
2803 case mfPUSHUDNS:
2804 case mfPUSHLRNS:
2805 case mfPUSH4NS:
2806 case mfPUSHUNS:
2807 case mfPUSHDNS:
2808 case mfPUSHLNS:
2809 case mfPUSHRNS:
2810 case mfPUSHUDINS:
2811 case mfPUSHLRINS:
2812 case mfPUSH4INS:
2813 case mfPUSHUINS:
2814 case mfPUSHDINS:
2815 case mfPUSHLINS:
2816 case mfPUSHRINS:
2817
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2818
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2819 {
2820 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2821 }
2822
2823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2824
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2825 {
2826
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2827 {
2828
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2829 {
2830 case cPUSH_HEAVY:
2831 case cPUSH_HW:
2832 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2833 72 tempitemx=x, tempitemy=y;
2834
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2836 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837
2838 72 break;
2839
2840 case cPUSH_HEAVY2:
2841 case cPUSH_HW2:
2842 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2843 63 tempitemx=x, tempitemy=y;
2844
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2846 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2847
2848 63 break;
2849 }
2850 1032 }
2851 2438 }
2852
2853 3148 break;
2854
2855 case mfWHISTLE:
2856
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2857 {
2858 tempitem=getItemID(itemsbuf,itype_whistle,1);
2859
2860 if(tempitem<0) break;
2861
2862 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2863 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2864 {
2865 tempitemx=x;
2866 tempitemy=y;
2867 }
2868
2869 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2870 }
2871
2872 2418 break;
2873
2874 //Why is this here?
2875 case mfFAIRY:
2876 case mfMAGICFAIRY:
2877 case mfALLFAIRY:
2878 if(hints)
2879 {
2880 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2881
2882 if(tempitem < 0) break;
2883
2884 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2885 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2886 {
2887 tempitemx=x;
2888 tempitemy=y;
2889 }
2890
2891 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2892 }
2893
2894 break;
2895
2896 case mfANYFIRE:
2897
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2898 {
2899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2900 252 }
2901 else
2902 {
2903 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2904
2905
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2906
2907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2908
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2909 {
2910 189 tempitemx=x;
2911 189 tempitemy=y;
2912 189 }
2913
2914 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2915 }
2916
2917 504 break;
2918
2919 case mfSTRONGFIRE:
2920 if(!hints)
2921 {
2922 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2923 }
2924 else
2925 {
2926 tempitem=getItemID(itemsbuf,itype_candle,2);
2927
2928 if(tempitem<0) break;
2929
2930 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2931 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2932 {
2933 tempitemx=x;
2934 tempitemy=y;
2935 }
2936
2937 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2938 }
2939
2940 break;
2941
2942 case mfMAGICFIRE:
2943 if(!hints)
2944 {
2945 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2946 }
2947 else
2948 {
2949 tempitem=getItemID(itemsbuf,itype_wand,1);
2950
2951 if(tempitem<0) break;
2952
2953 tempweapon=wFire;
2954
2955 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2956 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2957 {
2958 tempitemx=x;
2959 tempitemy=y;
2960 }
2961 else
2962 {
2963 tempweaponx=x;
2964 tempweapony=y;
2965 }
2966
2967 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2969 }
2970
2971 break;
2972
2973 case mfDIVINEFIRE:
2974 if(!hints)
2975 {
2976 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2977 }
2978 else
2979 {
2980 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2981
2982 if(tempitem<0) break;
2983
2984 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2985 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2986 {
2987 tempitemx=x;
2988 tempitemy=y;
2989 }
2990
2991 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2992 }
2993
2994 break;
2995
2996 case mfARROW:
2997
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2998 {
2999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3000 732 }
3001 else
3002 {
3003 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3004
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3006
3007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3008
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3009 {
3010 61 tempitemx=x;
3011 61 tempitemy=y;
3012 61 }
3013
3014 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3015 }
3016
3017 814 break;
3018
3019 case mfSARROW:
3020 if(!hints)
3021 {
3022 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3023 }
3024 else
3025 {
3026 tempitem=getItemID(itemsbuf,itype_arrow,2);
3027
3028 if(tempitem<0) break;
3029
3030 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3031 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3032 {
3033 tempitemx=x;
3034 tempitemy=y;
3035 }
3036
3037 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3038 }
3039
3040 break;
3041
3042 case mfGARROW:
3043 if(!hints)
3044 {
3045 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3046 }
3047 else
3048 {
3049 tempitem=getItemID(itemsbuf,itype_arrow,3);
3050
3051 if(tempitem<0) break;
3052
3053 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3054 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3055 {
3056 tempitemx=x;
3057 tempitemy=y;
3058 }
3059
3060 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3061 }
3062
3063 break;
3064
3065 case mfBOMB:
3066
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3067 {
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3069 16 }
3070 else
3071 {
3072 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3073 17 tempweapon = wLitBomb;
3074
3075 //if (tempitem<0) break;
3076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3077
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3078 {
3079 12 tempweaponx=x;
3080 12 tempweapony=y;
3081 12 }
3082
3083 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3084 }
3085
3086 33 break;
3087
3088 case mfSBOMB:
3089
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3090 {
3091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3092 48 }
3093 else
3094 {
3095 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3096 //if (tempitem<0) break;
3097 48 tempweapon = wLitSBomb;
3098
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3100
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3101 {
3102 36 tempweaponx=x;
3103 36 tempweapony=y;
3104 36 }
3105
3106 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3107 }
3108
3109 96 break;
3110
3111 case mfARMOS_SECRET:
3112
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3113 {
3114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3115 12 }
3116 24 break;
3117
3118 case mfBRANG:
3119
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3120 {
3121 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3122 }
3123 else
3124 {
3125 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3126
3127
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3128
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3130
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3131 {
3132 4 tempitemx=x;
3133 4 tempitemy=y;
3134 4 }
3135
3136 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3137 }
3138
3139 5 break;
3140
3141 case mfMBRANG:
3142 if(!hints)
3143 {
3144 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3145 }
3146 else
3147 {
3148 tempitem=getItemID(itemsbuf,itype_brang,2);
3149
3150 if(tempitem<0) break;
3151
3152 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3153 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3154 {
3155 tempitemx=x;
3156 tempitemy=y;
3157 }
3158
3159 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3160 }
3161
3162 break;
3163
3164 case mfFBRANG:
3165 if(!hints)
3166 {
3167 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3168 }
3169 else
3170 {
3171 tempitem=getItemID(itemsbuf,itype_brang,3);
3172
3173 if(tempitem<0) break;
3174
3175 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3176 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3177 {
3178 tempitemx=x;
3179 tempitemy=y;
3180 }
3181
3182 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3183 }
3184
3185 break;
3186
3187 case mfWANDMAGIC:
3188 if(!hints)
3189 {
3190 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3191 }
3192 else
3193 {
3194 tempitem=getItemID(itemsbuf,itype_wand,1);
3195
3196 if(tempitem<0) break;
3197
3198 tempweapon=itemsbuf[tempitem].wpn3;
3199
3200 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3201 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3202 {
3203 tempitemx=x;
3204 tempitemy=y;
3205 }
3206 else
3207 {
3208 tempweaponx=x;
3209 tempweapony=y;
3210 --lens_hint_weapon[wMagic][4];
3211
3212 if(lens_hint_weapon[wMagic][4]<-8)
3213 {
3214 lens_hint_weapon[wMagic][4]=8;
3215 }
3216 }
3217
3218 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3219 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3220 }
3221
3222 break;
3223
3224 case mfREFMAGIC:
3225
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3226 {
3227 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3228 }
3229 else
3230 {
3231 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3232
3233
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3234
3235 16 tempweapon=ewMagic;
3236
3237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3238
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3239 {
3240 13 tempitemx=x;
3241 13 tempitemy=y;
3242 13 }
3243 else
3244 {
3245 3 tempweaponx=x;
3246 3 tempweapony=y;
3247
3248
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3249 {
3250 1 --lens_hint_weapon[ewMagic][4];
3251 1 }
3252 else
3253 {
3254 2 ++lens_hint_weapon[ewMagic][4];
3255 }
3256
3257
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3258 {
3259 lens_hint_weapon[ewMagic][2]=up;
3260 }
3261
3262
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3263 {
3264 2 lens_hint_weapon[ewMagic][2]=down;
3265 2 }
3266 }
3267
3268 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3269 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3270 }
3271
3272 16 break;
3273
3274 case mfREFFIREBALL:
3275
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3276 {
3277 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3278 }
3279 else
3280 {
3281 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3282
3283
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3284
3285 16 tempweapon=ewFireball;
3286
3287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3288
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3289 {
3290 12 tempitemx=x;
3291 12 tempitemy=y;
3292 12 tempweaponx=x;
3293 12 tempweapony=y;
3294 12 ++lens_hint_weapon[ewFireball][3];
3295
3296
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3297 {
3298 1 lens_hint_weapon[ewFireball][3]=-8;
3299 1 lens_hint_weapon[ewFireball][4]=8;
3300 1 }
3301
3302
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3303 {
3304 8 ++lens_hint_weapon[ewFireball][4];
3305 8 }
3306 else
3307 {
3308 4 --lens_hint_weapon[ewFireball][4];
3309 }
3310 12 }
3311
3312 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3313 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3314 }
3315
3316 16 break;
3317
3318 case mfSWORD:
3319
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3320 {
3321 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3322 }
3323 else
3324 {
3325 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3326
3327
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3328
3329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3330
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3331 {
3332 5 tempitemx=x;
3333 5 tempitemy=y;
3334 5 }
3335
3336 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3337 }
3338
3339 7 break;
3340
3341 case mfWSWORD:
3342 if(!hints)
3343 {
3344 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3345 }
3346 else
3347 {
3348 tempitem=getItemID(itemsbuf,itype_sword,2);
3349
3350 if(tempitem<0) break;
3351
3352 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3353 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3354 {
3355 tempitemx=x;
3356 tempitemy=y;
3357 }
3358
3359 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3360 }
3361
3362 break;
3363
3364 case mfMSWORD:
3365 if(!hints)
3366 {
3367 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3368 }
3369 else
3370 {
3371 tempitem=getItemID(itemsbuf,itype_sword,3);
3372
3373 if(tempitem<0) break;
3374
3375 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3376 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3377 {
3378 tempitemx=x;
3379 tempitemy=y;
3380 }
3381
3382 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3383 }
3384
3385 break;
3386
3387 case mfXSWORD:
3388 if(!hints)
3389 {
3390 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3391 }
3392 else
3393 {
3394 tempitem=getItemID(itemsbuf,itype_sword,4);
3395
3396 if(tempitem<0) break;
3397
3398 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3399 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3400 {
3401 tempitemx=x;
3402 tempitemy=y;
3403 }
3404
3405 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3406 }
3407
3408 break;
3409
3410 case mfSWORDBEAM:
3411
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3412 {
3413 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3414 }
3415 else
3416 {
3417 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3418
3419
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3420
3421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3422
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3423 {
3424 11 tempitemx=x;
3425 11 tempitemy=y;
3426 11 }
3427
3428 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3429 }
3430
3431 16 break;
3432
3433 case mfWSWORDBEAM:
3434 if(!hints)
3435 {
3436 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3437 }
3438 else
3439 {
3440 tempitem=getItemID(itemsbuf,itype_sword,2);
3441
3442 if(tempitem<0) break;
3443
3444 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3445 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3446 {
3447 tempitemx=x;
3448 tempitemy=y;
3449 }
3450
3451 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3452 }
3453
3454 break;
3455
3456 case mfMSWORDBEAM:
3457 if(!hints)
3458 {
3459 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3460 }
3461 else
3462 {
3463 tempitem=getItemID(itemsbuf,itype_sword,3);
3464
3465 if(tempitem<0) break;
3466
3467 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3468 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3469 {
3470 tempitemx=x;
3471 tempitemy=y;
3472 }
3473
3474 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3475 }
3476
3477 break;
3478
3479 case mfXSWORDBEAM:
3480 if(!hints)
3481 {
3482 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3483 }
3484 else
3485 {
3486 tempitem=getItemID(itemsbuf,itype_sword,4);
3487
3488 if(tempitem<0) break;
3489
3490 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3491 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3492 {
3493 tempitemx=x;
3494 tempitemy=y;
3495 }
3496
3497 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3498 }
3499
3500 break;
3501
3502 case mfHOOKSHOT:
3503
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3504 {
3505 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3506 }
3507 else
3508 {
3509 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3510
3511
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3512
3513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3514
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3515 {
3516 12 tempitemx=x;
3517 12 tempitemy=y;
3518 12 }
3519
3520 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3521 }
3522
3523 17 break;
3524
3525 case mfWAND:
3526
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3527 {
3528 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3529 }
3530 else
3531 {
3532 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3533
3534
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3535
3536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3537
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3538 {
3539 28 tempitemx=x;
3540 28 tempitemy=y;
3541 28 }
3542
3543 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3544 }
3545
3546 35 break;
3547
3548 case mfHAMMER:
3549
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3550 {
3551 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3552 }
3553 else
3554 {
3555 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3556
3557
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3558
3559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3560
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3561 {
3562 13 tempitemx=x;
3563 13 tempitemy=y;
3564 13 }
3565
3566 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3567 }
3568
3569 17 break;
3570
3571 case mfARMOS_ITEM:
3572 case mfDIVE_ITEM:
3573
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3574 {
3575 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3576 2064 }
3577 2064 break;
3578
3579 case 16:
3580 case 17:
3581 case 18:
3582 case 19:
3583 case 20:
3584 case 21:
3585 case 22:
3586 case 23:
3587 case 24:
3588 case 25:
3589 case 26:
3590 case 27:
3591 case 28:
3592 case 29:
3593 case 30:
3594 case 31:
3595
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3597 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3598
3599 3618 break;
3600 case mfSECRETSNEXT:
3601 if(!hints)
3602 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3603 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3604
3605 break;
3606
3607 case mfSTRIKE:
3608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3609 {
3610 906 goto special;
3611 }
3612 else
3613 {
3614 break;
3615 }
3616
3617 28640 default: goto special;
3618
3619 special:
3620
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3621 {
3622
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3623 {
3624 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3625 4913 }
3626 6549 }
3627
3628 29546 break;
3629 }
3630 5748864 }
3631 2874432 }
3632
3633
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3634 {
3635
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3636 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3637
3638
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3639 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3640
3641
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3642 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3643
3644
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3645 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3646
3647
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3648 {
3649 43 showbombeddoor(dest, 0);
3650 43 }
3651
3652
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3653 {
3654 39 showbombeddoor(dest, 1);
3655 39 }
3656
3657
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3658 {
3659 showbombeddoor(dest, 2);
3660 }
3661
3662
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3663 {
3664 37 showbombeddoor(dest, 3);
3665 37 }
3666 8166 }
3667
3668
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3669 {
3670
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3671 {
3672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3673 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3674 1123 }
3675 else
3676 {
3677
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3678 {
3679 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3680 48 int32_t tempitemx=-16;
3681 48 int32_t tempitemy=-16;
3682
3683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3684
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3685 {
3686 24 tempitemx=tmpscr->stairx;
3687 24 tempitemy=tmpscr->stairy+playing_field_offset;
3688 24 }
3689
3690 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3691 48 }
3692 }
3693 2034 }
3694 }
3695 16332 }
3696
3697 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3698
3699 7997 void draw_lens_over()
3700 {
3701 // Oh, what the heck.
3702 static BITMAP *lens_scr = NULL;
3703 static int32_t last_width = -1;
3704 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3705
3706 // Only redraw the circle if the size has changed
3707
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3708 {
3709
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3710 {
3711 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3712 10 }
3713
3714 10 clear_to_color(lens_scr, BLACK);
3715 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3716 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3717 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3718 10 last_width=width;
3719 10 }
3720
3721 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3722 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3723 7997 }
3724
3725 //----------------------------------------------------------------
3726
3727 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3728 {
3729 //recreating a big bitmap every frame is highly sluggish.
3730
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3731 31111 clear_to_color(wavebuf, BLACK);
3732 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3733
3734 int32_t ofs;
3735 // int32_t amplitude=8;
3736 // int32_t wavelength=4;
3737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3738
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3739 31111 int32_t amp2=168;
3740
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3741 31111 int32_t i=frame%amp2;
3742
3743
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3744 {
3745
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3746 {
3747 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3748 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3749 }
3750 else
3751 {
3752 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3753 }
3754
3755
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3756 {
3757
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3758 {
3759 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3760 1338021888 }
3761 5226648 }
3762 5226648 }
3763 31111 }
3764
3765 4848 void draw_fuzzy(int32_t fuzz)
3766 // draws from right half of scrollbuf to framebuf
3767 {
3768 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3769 byte *start, *si, *di;
3770
3771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3772 fuzz = 1;
3773
3774 4848 xstep = 128%fuzz;
3775
3776
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3777 3838 xstep = fuzz-xstep;
3778
3779 4848 ystep = 112%fuzz;
3780
3781
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3782 3434 ystep = fuzz-ystep;
3783
3784 4848 firsty = 1;
3785
3786
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3787 {
3788 174932 start = &(scrollbuf->line[y][256]);
3789
3790
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3791 {
3792 1085952 si = start;
3793 1085952 di = &(framebuf->line[y+dy][0]);
3794 1085952 i = xstep;
3795 1085952 firstx = 1;
3796
3797
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3798 {
3799 278003712 *(di++) = *si;
3800
3801
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3802 {
3803
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3804 42668864 si += fuzz;
3805 else
3806 {
3807 1085952 si += fuzz-xstep;
3808 1085952 firstx = 0;
3809 }
3810
3811 43754816 i = 0;
3812 43754816 }
3813 278003712 }
3814 1085952 }
3815
3816
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3817 170084 y += fuzz;
3818 else
3819 {
3820 4848 y += ystep;
3821 4848 ystep = fuzz;
3822 4848 firsty = 0;
3823 }
3824 }
3825 4848 }
3826
3827 9286804 void updatescr(bool allowwavy)
3828 {
3829
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286804 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3830
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9286804 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3831
3832
2/2
✓ Branch 0 taken 9260039 times.
✓ Branch 1 taken 26765 times.
9286804 if(toogam)
3833 {
3834 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3835 26765 }
3836
3837
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(Showpal)
3838 dump_pal(framebuf);
3839
3840
2/2
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
9286804 if(!Playing)
3841 301232 black_opening_count=0;
3842
3843
2/2
✓ Branch 0 taken 9213478 times.
✓ Branch 1 taken 73326 times.
9286804 if(black_opening_count<0) //shape is opening up
3844 {
3845 73326 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3846
3847
2/4
✓ Branch 0 taken 73326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73326 times.
73326 if(Advance||(!Paused))
3848 {
3849 73326 ++black_opening_count;
3850 73326 }
3851 73326 }
3852
2/2
✓ Branch 0 taken 9187342 times.
✓ Branch 1 taken 26136 times.
9213478 else if(black_opening_count>0) //shape is closing
3853 {
3854 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3855
3856
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3857 {
3858 26136 --black_opening_count;
3859 26136 }
3860 26136 }
3861
3862
3/4
✓ Branch 0 taken 9188849 times.
✓ Branch 1 taken 97955 times.
✓ Branch 2 taken 9188849 times.
✗ Branch 3 not taken.
9286804 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3863 {
3864 black_opening_shape = bosCIRCLE;
3865 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3866 refreshTints();
3867 refreshpal=true;
3868 }
3869
3870
2/2
✓ Branch 0 taken 9032603 times.
✓ Branch 1 taken 254201 times.
9286804 if(refreshpal)
3871 {
3872 254201 refreshpal=false;
3873 254201 RAMpal[253] = _RGB(0,0,0);
3874 254201 RAMpal[254] = _RGB(63,63,63);
3875 254201 hw_palette = &RAMpal;
3876 254201 update_hw_pal = true;
3877
3878 254201 create_rgb_table(&rgb_table, RAMpal, NULL);
3879 254201 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3880 254201 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3881
3882
2/2
✓ Branch 0 taken 65075456 times.
✓ Branch 1 taken 254201 times.
65329657 for(int32_t q=0; q<PAL_SIZE; q++)
3883 {
3884 65075456 trans_table2.data[0][q] = q;
3885 65075456 trans_table2.data[q][q] = q;
3886 65075456 }
3887 254201 }
3888
3889 9286804 bool clearwavy = (wavy <= 0);
3890
3891
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9279149 times.
9286804 if(wavy <= 0)
3892 {
3893 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3894 9279149 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3895 9279149 }
3896
3897 9286804 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3898
3899
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9255443 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9286804 if(wavy && Playing && allowwavy)
3900 {
3901 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3902 31111 }
3903
3904
2/2
✓ Branch 0 taken 9279149 times.
✓ Branch 1 taken 7655 times.
9286804 if(clearwavy)
3905 9279149 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3906
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3907 7655 wavy--; // Wavy was set by a script. Decrement it.
3908
3909
5/6
✓ Branch 0 taken 8985572 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8725998 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9286804 if(Playing && msgpos && !screenscrolling)
3910 {
3911
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3912 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3913
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3914 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3915
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3916 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3917 259574 }
3918
3919 /*
3920 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3921 {
3922 BITMAP* subBmp = 0;
3923 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3924 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3925 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3926 destroy_bitmap(subBmp);
3927 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3928 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3929 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3930 }
3931 */
3932
3933
2/2
✓ Branch 0 taken 9245747 times.
✓ Branch 1 taken 41057 times.
9286804 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3934
3935
2/2
✓ Branch 0 taken 9250372 times.
✓ Branch 1 taken 36432 times.
9286804 if(nosubscr)
3936 {
3937 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3938 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3939 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3940 36432 }
3941
3942 //TODO: Optimize blit 'overcalls' -Gleeok
3943
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9250372 times.
9286804 BITMAP *source = nosubscr ? panorama : wavybuf;
3944 9286804 blit(source,framebuf,0,0,0,0,256,224);
3945
3946 9286804 update_hw_screen();
3947 9286804 }
3948
3949 //----------------------------------------------------------------
3950
3951 static PALETTE syspal;
3952 int32_t onGUISnapshot()
3953 {
3954 char buf[200];
3955 int32_t num=0;
3956 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3957 do
3958 {
3959 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3960 }
3961 while(num<99999 && exists(buf));
3962
3963 BITMAP *b = create_bitmap_ex(8,resx,resy);
3964
3965 if(b)
3966 {
3967 blit(screen,b,0,0,0,0,resx,resy);
3968 save_bitmap(buf,screen,RAMpal);
3969 destroy_bitmap(b);
3970 }
3971
3972 return D_O_K;
3973 }
3974
3975 int32_t onNonGUISnapshot()
3976 {
3977 PALETTE temppal;
3978 get_palette(temppal);
3979 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3980
3981 char buf[200];
3982 int32_t num=0;
3983
3984 do
3985 {
3986 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3987 }
3988 while(num<99999 && exists(buf));
3989
3990 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3991 {
3992 BITMAP *b = create_bitmap_ex(8,256,168);
3993 clear_to_color(b,0);
3994 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3995 save_bitmap(buf,b,realpal?temppal:RAMpal);
3996 destroy_bitmap(b);
3997 }
3998 else
3999 {
4000 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4001 }
4002
4003 return D_O_K;
4004 }
4005
4006 int32_t onSnapshot()
4007 {
4008 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4009 {
4010 onGUISnapshot();
4011 }
4012 else
4013 {
4014 onNonGUISnapshot();
4015 }
4016
4017 return D_O_K;
4018 }
4019
4020 int32_t onSaveMapPic()
4021 {
4022 int32_t mapres2 = 0;
4023 char buf[200];
4024 int32_t num=0;
4025 mapscr tmpscr_b[2];
4026 mapscr tmpscr_c[6];
4027 BITMAP* _screen_draw_buffer = NULL;
4028 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4029 set_clip_state(_screen_draw_buffer,1);
4030
4031 for(int32_t i=0; i<6; ++i)
4032 {
4033 tmpscr_c[i] = tmpscr2[i];
4034 tmpscr2[i].zero_memory();
4035
4036 if(i>=2)
4037 {
4038 continue;
4039 }
4040
4041 tmpscr_b[i] = tmpscr[i];
4042 tmpscr[i].zero_memory();
4043 }
4044
4045 do
4046 {
4047 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4048 }
4049 while(num<99999 && exists(buf));
4050
4051 BITMAP* mappic = NULL;
4052
4053
4054 bool done=false, redraw=true;
4055
4056 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4057
4058 if(!mappic)
4059 {
4060 enter_sys_pal();
4061 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4062 exit_sys_pal();
4063 return D_O_K;;
4064 }
4065
4066 // draw the map
4067 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4068
4069 for(int32_t y=0; y<8; y++)
4070 {
4071 for(int32_t x=0; x<16; x++)
4072 {
4073 if(!displayOnMap(x, y))
4074 {
4075 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4076 }
4077 else
4078 {
4079 int32_t s = (y<<4) + x;
4080 loadscr2(1,s,-1);
4081
4082 for(int32_t i=0; i<6; i++)
4083 {
4084 if(tmpscr[1].layermap[i]<=0)
4085 continue;
4086
4087 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4088 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4089 {
4090 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4091
4092 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4093 }
4094 }
4095
4096 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4097
4098 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4099
4100 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4101 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4102
4103 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4104
4105 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4106 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4107 {
4108 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4109 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4110 {
4111 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4112 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4113 }
4114 }
4115 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4116
4117 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4120 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4121 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4122 {
4123 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4124 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4125 }
4126 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4127 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4128
4129 }
4130
4131 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4132 }
4133 }
4134
4135 for(int32_t i=0; i<6; ++i)
4136 {
4137 tmpscr2[i]=tmpscr_c[i];
4138
4139 if(i>=2)
4140 {
4141 continue;
4142 }
4143
4144 tmpscr[i]=tmpscr_b[i];
4145 }
4146
4147 save_bitmap(buf,mappic,RAMpal);
4148 destroy_bitmap(mappic);
4149 destroy_bitmap(_screen_draw_buffer);
4150 return D_O_K;
4151 }
4152
4153 14 void f_Quit(int32_t type)
4154 {
4155
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4156 return;
4157
4158 14 bool from_menu = is_sys_pal;
4159
4160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4161 {
4162 14 music_pause();
4163 14 pause_all_sfx();
4164 14 sys_mouse();
4165 14 }
4166 14 enter_sys_pal();
4167 14 clear_keybuf();
4168
4169
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4170 13 replay_poll();
4171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4172 14 replay_peek_quit();
4173
4174
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4175 switch(type)
4176 {
4177 case qQUIT:
4178 onQuit();
4179 break;
4180
4181 case qRESET:
4182 onReset();
4183 break;
4184
4185 case qEXIT:
4186 onExit();
4187 break;
4188 }
4189
4190
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4191 {
4192 14 kill_sfx();
4193 14 music_stop();
4194 14 exit_sys_pal();
4195 14 update_hw_screen();
4196 14 }
4197 else
4198 {
4199 exit_sys_pal();
4200 if(!from_menu)
4201 {
4202 music_resume();
4203 resume_all_sfx();
4204 }
4205 }
4206
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4208 14 game_mouse();
4209 14 eat_buttons();
4210
4211 14 zc_readrawkey(KEY_ESC);
4212
4213 14 zc_readrawkey(KEY_ENTER);
4214 14 }
4215
4216 //----------------------------------------------------------------
4217
4218 int32_t onNoWalls()
4219 {
4220 cheats_enqueue(Cheat::Walls);
4221 return D_O_K;
4222 }
4223
4224 int32_t onIgnoreSideview()
4225 {
4226 cheats_enqueue(Cheat::IgnoreSideView);
4227 return D_O_K;
4228 }
4229
4230 9286678 int32_t input_idle(bool checkmouse)
4231 {
4232 static int32_t mx, my, mz, mb;
4233
4234
4/6
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✓ Branch 3 taken 6825041 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461637 times.
11748315 if(keypressed() || zc_key_pressed() ||
4235
4/8
✓ Branch 0 taken 2461637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461637 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461637 times.
✗ Branch 7 not taken.
2461637 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4236 {
4237 6825041 idle_count = 0;
4238
4239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6825041 times.
6825041 if(active_count < MAX_ACTIVE)
4240 {
4241 6825041 ++active_count;
4242 6825041 }
4243 6825041 }
4244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461637 times.
2461637 else if(idle_count < MAX_IDLE)
4245 {
4246 2461637 ++idle_count;
4247 2461637 active_count = 0;
4248 2461637 }
4249
4250 9286678 mx = mouse_x;
4251 9286678 my = mouse_y;
4252 9286678 mz = mouse_z;
4253 9286678 mb = mouse_b;
4254
4255 9286678 return idle_count;
4256 }
4257
4258 int32_t onGoFast()
4259 {
4260 cheats_enqueue(Cheat::Fast);
4261 return D_O_K;
4262 }
4263
4264 int32_t onKillCheat()
4265 {
4266 cheats_enqueue(Cheat::Kill);
4267 return D_O_K;
4268 }
4269
4270 int32_t onSecretsCheat()
4271 {
4272 cheats_enqueue(Cheat::TrigSecrets);
4273 return D_O_K;
4274 }
4275 int32_t onSecretsCheatPerm()
4276 {
4277 cheats_enqueue(Cheat::TrigSecretsPerm);
4278 return D_O_K;
4279 }
4280
4281 int32_t onShowLayer0()
4282 {
4283 show_layer_0 = !show_layer_0;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayer1()
4287 {
4288 show_layer_1 = !show_layer_1;
4289 return D_O_K;
4290 }
4291 int32_t onShowLayer2()
4292 {
4293 show_layer_2 = !show_layer_2;
4294 return D_O_K;
4295 }
4296 int32_t onShowLayer3()
4297 {
4298 show_layer_3 = !show_layer_3;
4299 return D_O_K;
4300 }
4301 int32_t onShowLayer4()
4302 {
4303 show_layer_4 = !show_layer_4;
4304 return D_O_K;
4305 }
4306 int32_t onShowLayer5()
4307 {
4308 show_layer_5 = !show_layer_5;
4309 return D_O_K;
4310 }
4311 int32_t onShowLayer6()
4312 {
4313 show_layer_6 = !show_layer_6;
4314 return D_O_K;
4315 }
4316 int32_t onShowLayerO()
4317 {
4318 show_layer_over=!show_layer_over;
4319 return D_O_K;
4320 }
4321 int32_t onShowLayerP()
4322 {
4323 show_layer_push=!show_layer_push;
4324 return D_O_K;
4325 }
4326 int32_t onShowLayerS()
4327 {
4328 show_sprites=!show_sprites;
4329 return D_O_K;
4330 }
4331 int32_t onShowLayerF()
4332 {
4333 show_ffcs=!show_ffcs;
4334 return D_O_K;
4335 }
4336 int32_t onShowLayerW()
4337 {
4338 show_walkflags=!show_walkflags;
4339 if(show_walkflags)
4340 show_effectflags = false;
4341 return D_O_K;
4342 }
4343 int32_t onShowLayerE()
4344 {
4345 show_effectflags=!show_effectflags;
4346 if(show_effectflags)
4347 show_walkflags = false;
4348 return D_O_K;
4349 }
4350 int32_t onShowFFScripts()
4351 {
4352 show_ff_scripts=!show_ff_scripts;
4353 return D_O_K;
4354 }
4355 int32_t onShowHitboxes()
4356 {
4357 show_hitboxes=!show_hitboxes;
4358 return D_O_K;
4359 }
4360 int32_t onShowInfoOpacity()
4361 {
4362 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4363 zc_set_config("zc","debug_info_opacity",info_opacity);
4364 return D_O_K;
4365 }
4366
4367 int32_t onLightSwitch()
4368 {
4369 cheats_enqueue(Cheat::Light);
4370 return D_O_K;
4371 }
4372
4373 int32_t onGoTo();
4374 int32_t onGoToComplete();
4375
4376 9286678 bool handle_close_btn_quit()
4377 {
4378
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(close_button_quit)
4379 {
4380 close_button_quit=false;
4381 f_Quit(qEXIT);
4382 }
4383 9286678 return (exiting_program = Quit==qEXIT);
4384 }
4385
4386 9286678 void syskeys()
4387 {
4388 9286678 update_system_keys();
4389
4390 int32_t oldtitle_version;
4391
4392 9286678 poll_joystick();
4393
4394 9286678 handle_close_btn_quit();
4395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(Quit == qEXIT) return;
4396
4397
2/10
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9286678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9286678 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4398 {
4399 System();
4400 }
4401
4402 9286678 mouse_down=gui_mouse_b();
4403
4404
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F1))
4405 {
4406 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4407 {
4408 halt=!halt;
4409 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4410 }
4411 else
4412 {
4413 Throttlefps=!Throttlefps;
4414 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4415 }
4416 }
4417
4418 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4419 /*
4420 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4421 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4422 */
4423
4424
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F2))
4425 {
4426 ShowFPS=!ShowFPS;
4427 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4428 }
4429
4430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4431
4432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(zc_read_system_key(KEY_F4) && Playing)
4433 {
4434 Paused=true;
4435 Advance=true;
4436 }
4437
4438
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F6)) onTryQuit();
4439
4440 #ifndef ALLEGRO_MACOSX
4441
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4442
4443
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4444 #else
4445 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4446
4447 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4448 #endif
4449
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9286678 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4450
4451
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (zc_read_system_key(KEY_F12))
4452 {
4453 onSnapshot();
4454 }
4455
4456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286678 if(debug_enabled && zc_read_system_key(KEY_TAB))
4457 set_debug(!get_debug());
4458
4459
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(CheatModifierKeys())
4460 {
4461 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4462 {
4463 if(!bindable_cheat(c))
4464 continue;
4465 if(get_debug() || cheat >= cheat_lvl(c))
4466 {
4467 if(checkcheat(c))
4468 cheats_hit_bind(c);
4469 }
4470 }
4471 }
4472
4473
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(volkeys)
4474 {
4475 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4476
4477 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4478
4479 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4480
4481 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4482 }
4483
4484
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9286678 if(!get_debug() || !SystemKeys || replay_is_replaying())
4485 9286678 goto bottom;
4486
4487 if(zc_readkey(KEY_D))
4488 {
4489 details = !details;
4490 rectfill(screen,0,0,319,7,BLACK);
4491 rectfill(screen,0,8,31,239,BLACK);
4492 rectfill(screen,288,8,319,239,BLACK);
4493 rectfill(screen,32,232,287,239,BLACK);
4494 }
4495
4496 if(zc_readkey(KEY_P)) Paused=!Paused;
4497
4498 //if(zc_readkey(KEY_P)) centerHero();
4499 if(zc_readkey(KEY_A))
4500 {
4501 Paused=true;
4502 Advance=true;
4503 }
4504
4505 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4506 #ifndef ALLEGRO_MACOSX
4507 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4508
4509 if(zc_readkey(KEY_F7))
4510 {
4511 Matrix(ss_speed, ss_density, 0);
4512 game_pal();
4513 }
4514 #else
4515 // The reason these are different on Mac in the first place is that
4516 // the OS doesn't let us use F9 and F10...
4517 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4518
4519 if(zc_readkey(KEY_F9))
4520 {
4521 Matrix(ss_speed, ss_density, 0);
4522 game_pal();
4523 }
4524 #endif
4525 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4526 {
4527 //change containers
4528 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4529 {
4530 //magic containers
4531 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4532 {
4533 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4534 }
4535 else
4536 {
4537 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4538 }
4539 }
4540 else
4541 {
4542 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4543 {
4544 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4545 }
4546 else
4547 {
4548 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4549 }
4550 }
4551 }
4552
4553 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4554 {
4555 //change containers
4556 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4557 {
4558 //magic containers
4559 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4560 {
4561 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4562 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4563 //heart containers
4564 }
4565 else
4566 {
4567 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4568 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4569 }
4570 }
4571 else
4572 {
4573 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4574 {
4575 game->set_magic(zc_max(game->get_magic()-1,0));
4576 }
4577 else
4578 {
4579 game->set_life(zc_max(game->get_life()-1,0));
4580 }
4581 }
4582 }
4583
4584 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4585
4586 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4587
4588 verifyBothWeapons();
4589
4590 bottom:
4591
4592
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(input_idle(true) > after_time())
4593 {
4594 Matrix(ss_speed, ss_density, 0);
4595 game_pal();
4596 }
4597 9286678 }
4598
4599 708283 void checkQuitKeys()
4600 {
4601 #ifndef ALLEGRO_MACOSX
4602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F9]) f_Quit(qRESET);
4603
4604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708283 times.
708283 if(key[KEY_F10]) f_Quit(qEXIT);
4605 #else
4606 if(key[KEY_F7]) f_Quit(qRESET);
4607
4608 if(key[KEY_F8]) f_Quit(qEXIT);
4609 #endif
4610 708283 }
4611
4612 9286678 bool CheatModifierKeys()
4613 {
4614 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4615 // to trigger cheats.
4616
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if (replay_is_replaying())
4617 9286678 return false;
4618
4619 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4620 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4621 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4622 {
4623 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4624 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4625 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4626 {
4627 return true;
4628 }
4629 }
4630 return false;
4631 9286678 }
4632
4633 //99:05:54, for some reason?
4634 #define OLDMAXTIME 21405240
4635 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4636 #define MAXTIME 1944000000
4637
4638 9286804 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4639 {
4640
1/2
✓ Branch 0 taken 9286804 times.
✗ Branch 1 not taken.
9286804 if(zcmusic!=NULL)
4641 {
4642 zcmusic_poll();
4643 }
4644 9286804 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4645
4646 9286804 updatescr(allowwavy);
4647
4648 9286804 Advance=false;
4649
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9286804 times.
9286804 while(Paused && !Advance && !Quit)
4650 {
4651 // have to call this, otherwise we'll get an infinite loop
4652 syskeys();
4653 if(allowF6Script)
4654 {
4655 FFCore.runF6Engine();
4656 }
4657 throttleFPS();
4658
4659 #ifdef _WIN32
4660
4661 if(use_dwm_flush)
4662 {
4663 do_DwmFlush();
4664 }
4665
4666 #endif
4667
4668 // to keep music playing
4669 if(zcmusic!=NULL)
4670 {
4671 zcmusic_poll();
4672 }
4673
4674 update_hw_screen();
4675 }
4676
4677
2/2
✓ Branch 0 taken 9286692 times.
✓ Branch 1 taken 112 times.
9286804 if(Quit)
4678 112 return;
4679
4680
3/4
✓ Branch 0 taken 8985563 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8985563 times.
9286692 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4681 8985563 game->change_time(1);
4682
4683 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4684
4685 9286692 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4686
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 9266797 times.
9286692 if (replay_version_check(0, 16))
4687 9266797 should_reset_down_state = replay_version_check(11, 16);
4688
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2337012 times.
9286692 if (should_reset_down_state)
4689 {
4690
2/2
✓ Branch 0 taken 42066216 times.
✓ Branch 1 taken 2337012 times.
44403228 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4691 42066216 down_control_states[i] = raw_control_state[i];
4692 2337012 }
4693
4694
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_active())
4695 {
4696
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8016229 times.
9286678 if (replay_version_check(3))
4697 8016229 replay_poll();
4698
4699
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2340580 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9286678 if (replay_version_check(11) || replay_version_check(6, 8))
4700 2441115 replay_peek_input();
4701 9286678 }
4702
4703 9286692 load_control_called_this_frame = false;
4704
4705 9286692 poll_keyboard();
4706 9286692 update_keys();
4707
4708 9286692 ++frame;
4709
4710
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4711 9286678 replay_do_cheats();
4712 9286692 syskeys();
4713
4714 // The mouse variables can change from the mouse thread at anytime during a frame,
4715 // so save the result at the start so that replaying is consistent.
4716 9286692 script_mouse_x = gui_mouse_x();
4717 9286692 script_mouse_y = gui_mouse_y();
4718 9286692 script_mouse_z = mouse_z;
4719 9286692 script_mouse_b = mouse_b;
4720
4721 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4722 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4723 // approach here means it doesn't matter which call adds the cheat.
4724 9286692 cheats_execute_queued();
4725
4726
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9286678 times.
9286692 if (replay_is_replaying())
4727 9286678 replay_peek_quit();
4728
2/2
✓ Branch 0 taken 9286678 times.
✓ Branch 1 taken 14 times.
9286692 if (GameFlags & GAMEFLAG_TRYQUIT)
4729 14 replay_step_quit(0);
4730
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9283758 times.
9286692 if(allowF6Script)
4731 9283758 FFCore.runF6Engine();
4732
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 9286392 times.
9286692 if (Quit)
4733 300 replay_step_quit(Quit);
4734 // Someday... maybe install a Turbo button here?
4735 9286692 throttleFPS();
4736
4737 #ifdef _WIN32
4738
4739 if(use_dwm_flush)
4740 {
4741 do_DwmFlush();
4742 }
4743
4744 #endif
4745
4746 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4747
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9217934 times.
9286692 if(sfxcleanup)
4748 9217934 sfx_cleanup();
4749
4750 9286692 jit_poll();
4751
4752 #ifdef __EMSCRIPTEN__
4753 // Yield the main thread back to the browser occasionally.
4754 if (is_headless())
4755 {
4756 static int rate = 10000;
4757 static int force_yield = rate;
4758 if (force_yield++ >= rate)
4759 {
4760 force_yield = 0;
4761 emscripten_sleep(0);
4762 }
4763 }
4764 #endif
4765
4766
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9286576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9286692 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4767
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9286692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9286692 if (zqtesting_mode && test_mode_auto_restart)
4768 {
4769 static auto last_write_time = fs::last_write_time(qstpath);
4770 static auto last_check = std::chrono::system_clock::now();
4771
4772 if (std::chrono::system_clock::now() - last_check > 200ms)
4773 {
4774 last_check = std::chrono::system_clock::now();
4775 auto write_time = fs::last_write_time(qstpath);
4776 if (last_write_time != write_time)
4777 {
4778 last_write_time = write_time;
4779 disableClickToFreeze = false;
4780 Quit = qRESET;
4781 replay_quit();
4782 }
4783 }
4784 }
4785 9286804 }
4786
4787 101 void zapout()
4788 {
4789 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4790 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4791
4792 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4793 101 script_drawing_commands.Clear();
4794
4795 // zap out
4796
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4797 {
4798 2424 draw_fuzzy(i);
4799 2424 advanceframe(true);
4800
4801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4802 {
4803 break;
4804 }
4805 2424 }
4806 101 }
4807
4808 101 void zapin()
4809 {
4810 101 FFCore.warpScriptCheck();
4811 101 draw_screen(tmpscr);
4812 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4813 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4814 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4815
4816 // zap out
4817 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4818
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4819 {
4820 2424 draw_fuzzy(i);
4821 2424 advanceframe(true);
4822
4823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4824 {
4825 break;
4826 }
4827 2424 }
4828 101 }
4829
4830
4831 65 void wavyout(bool showhero)
4832 {
4833 65 draw_screen(tmpscr, showhero);
4834 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4835
4836 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4837 65 clear_to_color(wavebuf,0);
4838 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4839
4840 static PALETTE wavepal;
4841
4842 int32_t ofs;
4843 65 int32_t amplitude=8;
4844
4845 65 int32_t wavelength=4;
4846 65 double palpos=0, palstep=4, palstop=126;
4847
4848 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4849
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4850 {
4851
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4852 {
4853 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4854 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4855 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4856 698880 }
4857
4858 2730 palpos+=palstep;
4859
4860
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4861 {
4862 2730 hw_palette = &wavepal;
4863 2730 update_hw_pal = true;
4864 2730 }
4865 else
4866 {
4867 hw_palette = &RAMpal;
4868 update_hw_pal = true;
4869 }
4870
4871
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4872 {
4873
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4874 {
4875 117411840 ofs=0;
4876
4877
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4878 {
4879 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4880 28654080 }
4881
4882 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4883 117411840 }
4884 458640 }
4885
4886 2730 advanceframe(true);
4887
4888 // animate_combos();
4889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4890 break;
4891 2730 }
4892
4893 65 destroy_bitmap(wavebuf);
4894 65 }
4895
4896 65 void wavyin()
4897 {
4898 65 draw_screen(tmpscr);
4899 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4900
4901 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4902 65 clear_to_color(wavebuf,0);
4903 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4904
4905 static PALETTE wavepal;
4906
4907 //Breaks dark rooms.
4908 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4909 /*
4910 loadfullpal();
4911 loadlvlpal(DMaps[currdmap].color);
4912 ringcolor(false);
4913 */
4914 65 refreshpal=false;
4915 int32_t ofs;
4916 65 int32_t amplitude=8;
4917 65 int32_t wavelength=4;
4918 65 double palpos=168, palstep=4, palstop=126;
4919
4920 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4921
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4922 {
4923
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4924 {
4925 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4926 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4927 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4928 698880 }
4929
4930 2730 palpos-=palstep;
4931
4932
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4933 {
4934 2730 hw_palette = &wavepal;
4935 2730 update_hw_pal = true;
4936 2730 }
4937 else
4938 {
4939 hw_palette = &RAMpal;
4940 update_hw_pal = true;
4941 }
4942
4943
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4944 {
4945
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4946 {
4947 117411840 ofs=0;
4948
4949
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4950 {
4951 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4952 29352960 }
4953
4954 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4955 117411840 }
4956 458640 }
4957
4958 2730 advanceframe(true);
4959 // animate_combos();
4960
4961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4962 break;
4963 2730 }
4964
4965 65 destroy_bitmap(wavebuf);
4966 65 }
4967
4968 2168 void blackscr(int32_t fcnt,bool showsubscr)
4969 {
4970 2168 reset_pal_cycling();
4971 2168 script_drawing_commands.Clear();
4972
4973 2168 FFCore.warpScriptCheck();
4974 2168 bool showtime = game->should_show_time();
4975
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4976 {
4977 64970 clear_bitmap(framebuf);
4978
4979
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4980 {
4981 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4982
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4983 {
4984 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4985 750 }
4986 39890 }
4987
4988 64970 advanceframe(true);
4989
4990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4991 break;
4992
4993 64970 --fcnt;
4994 }
4995 2168 }
4996
4997 1012 void openscreen(int32_t shape)
4998 {
4999 1012 reset_pal_cycling();
5000 1012 black_opening_count=0;
5001
5002
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1012 if(COOLSCROLL || shape>-1)
5003 {
5004 912 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5005 912 return;
5006 }
5007 else
5008 {
5009 100 Hero.setDontDraw(true);
5010 100 show_subscreen_dmap_dots=false;
5011 100 show_subscreen_numbers=false;
5012 // show_subscreen_items=false;
5013 100 show_subscreen_life=false;
5014 }
5015
5016 100 int32_t x=128;
5017
5018 100 FFCore.warpScriptCheck();
5019
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
5020 {
5021 8000 draw_screen(tmpscr);
5022 //? draw_screen already draws the subscreen -DD
5023 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5024 8000 x=128-(((i*128/80)/8)*8);
5025
5026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
5027 {
5028 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5029 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5030 8000 }
5031
5032 8000 advanceframe(true);
5033
5034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5035 {
5036 break;
5037 }
5038 8000 }
5039
5040 100 Hero.setDontDraw(false);
5041 100 show_subscreen_items=true;
5042 100 show_subscreen_dmap_dots=true;
5043 1012 }
5044
5045 void closescreen(int32_t shape)
5046 {
5047 reset_pal_cycling();
5048 black_opening_count=0;
5049
5050 if(COOLSCROLL || shape>-1)
5051 {
5052 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5053 return;
5054 }
5055 else
5056 {
5057 Hero.setDontDraw(true);
5058 show_subscreen_dmap_dots=false;
5059 show_subscreen_numbers=false;
5060 // show_subscreen_items=false;
5061 show_subscreen_life=false;
5062 }
5063
5064 int32_t x=128;
5065
5066 FFCore.warpScriptCheck();
5067 for(int32_t i=79; i>=0; --i)
5068 {
5069 draw_screen(tmpscr);
5070 //? draw_screen already draws the subscreen -DD
5071 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5072 x=128-(((i*128/80)/8)*8);
5073
5074 if(x>0)
5075 {
5076 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5077 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5078 }
5079
5080 advanceframe(true);
5081
5082 if(Quit)
5083 {
5084 break;
5085 }
5086 }
5087
5088 Hero.setDontDraw(false);
5089 show_subscreen_items=true;
5090 show_subscreen_dmap_dots=true;
5091 }
5092
5093 179 int32_t TriforceCount()
5094 {
5095 179 int32_t c=0;
5096
5097
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5098
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5099 1044 ++c;
5100
5101 179 return c;
5102 }
5103
5104 int32_t onCustomGame()
5105 {
5106 int32_t file = getsaveslot();
5107
5108 if(file < 0)
5109 return D_O_K;
5110
5111 bool ret = (custom_game(file)!=0);
5112 return ret ? D_CLOSE : D_O_K;
5113 }
5114
5115 int32_t onContinue()
5116 {
5117 return D_CLOSE;
5118 }
5119
5120 int32_t onEsc() // Unused?? -L
5121 {
5122 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5123 }
5124
5125 int32_t onVsync()
5126 {
5127 Throttlefps = !Throttlefps;
5128 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5129 return D_O_K;
5130 }
5131
5132 int32_t onWinPosSave()
5133 {
5134 SaveWinPos = !SaveWinPos;
5135 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5136 return D_O_K;
5137 }
5138 int32_t onIntegerScaling()
5139 {
5140 scaleForceInteger = !scaleForceInteger;
5141 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5142 return D_O_K;
5143 }
5144 int32_t onStretchGame()
5145 {
5146 stretchGame = !stretchGame;
5147 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5148 return D_O_K;
5149 }
5150
5151 int32_t onClickToFreeze()
5152 {
5153 ClickToFreeze = !ClickToFreeze;
5154 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5155 return D_O_K;
5156 }
5157
5158 int32_t OnSaveZCConfig()
5159 {
5160 if(jwin_alert3(
5161 "Save Configuration",
5162 "Are you sure that you wish to save your present configuration settings?",
5163 "This will overwrite your prior settings!",
5164 NULL,
5165 "&Yes",
5166 "&No",
5167 NULL,
5168 'y',
5169 'n',
5170 0,
5171 get_zc_font(font_lfont)) == 1)
5172 {
5173 save_game_configs();
5174 return D_O_K;
5175 }
5176 else return D_O_K;
5177 }
5178
5179 int32_t OnnClearQuestDir()
5180 {
5181 if(jwin_alert3(
5182 "Clear Current Directory Cache",
5183 "Are you sure that you wish to clear the current cached directory?",
5184 "This will default the current directory to the ROOT for this instance of ZC Player!",
5185 NULL,
5186 "&Yes",
5187 "&No",
5188 NULL,
5189 'y',
5190 'n',
5191 0,
5192 get_zc_font(font_lfont)) == 1)
5193 {
5194 zc_set_config("zeldadx","win_qst_dir","");
5195 flush_config_file();
5196 strcpy(qstdir,"");
5197 #ifdef __EMSCRIPTEN__
5198 em_sync_fs();
5199 #endif
5200 return D_O_K;
5201 }
5202 else return D_O_K;
5203 }
5204
5205
5206 int32_t onConsoleZASM()
5207 {
5208 if ( !zasm_debugger )
5209 {
5210 AlertDialog("WARNING: ZASM Debugger",
5211 "Enabling this will open the ZASM Debugger Console"
5212 "\nThis will likely grind ZC to a halt with lag."
5213 "\nTo make any use of this, it is suggested that you read"
5214 "\nthe documentation for 'void Breakpoint(char[] string);'"
5215 " in 'ZScript_Additions.txt'"
5216 "\nThis is not recommended for normal users,"
5217 " and is only intended for ZC developers,"
5218 "\nor quest developers coding directly in ZASM"
5219 "\nAre you sure that you wish to open the ZASM Debugger?",
5220 [&](bool ret,bool)
5221 {
5222 if(ret)
5223 {
5224 FFCore.ZASMPrint(true);
5225 }
5226 }).show();
5227 return D_O_K;
5228 }
5229 else
5230 {
5231 FFCore.ZASMPrint(false);
5232 return D_O_K;
5233 }
5234 }
5235
5236
5237 int32_t onConsoleZScript()
5238 {
5239 if ( !zscript_debugger )
5240 {
5241 AlertDialog("ZScript Debugger",
5242 "Enabling this will open the ZScript Debugger Console"
5243 "\nThis will display any messages logged by scripts,"
5244 " including script errors."
5245 "\nAre you sure that you wish to open the ZScript Debugger?",
5246 [&](bool ret,bool)
5247 {
5248 if(ret)
5249 {
5250 FFCore.ZScriptConsole(true);
5251 }
5252 }).show();
5253 return D_O_K;
5254 }
5255 else
5256 {
5257 FFCore.ZScriptConsole(false);
5258 return D_O_K;
5259 }
5260 }
5261
5262 int32_t onClrConsoleOnReload()
5263 {
5264 clearConsoleOnReload = !clearConsoleOnReload;
5265 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5266 return D_O_K;
5267 }
5268 int32_t onClrConsoleOnLoad()
5269 {
5270 clearConsoleOnLoad = !clearConsoleOnLoad;
5271 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5272 return D_O_K;
5273 }
5274
5275
5276 int32_t onFrameSkip()
5277 {
5278 FrameSkip = !FrameSkip;
5279 return D_O_K;
5280 }
5281
5282 int32_t onSaveDragResize()
5283 {
5284 SaveDragResize = !SaveDragResize;
5285 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5286 return D_O_K;
5287 }
5288
5289 int32_t onDragAspect()
5290 {
5291 DragAspect = !DragAspect;
5292 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5293 return D_O_K;
5294 }
5295
5296 int32_t onTransLayers()
5297 {
5298 TransLayers = !TransLayers;
5299 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5300 return D_O_K;
5301 }
5302
5303 int32_t onNESquit()
5304 {
5305 NESquit = !NESquit;
5306 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5307 return D_O_K;
5308 }
5309
5310 int32_t onVolKeys()
5311 {
5312 volkeys = !volkeys;
5313 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5314 return D_O_K;
5315 }
5316
5317 int32_t onShowFPS()
5318 {
5319 ShowFPS = !ShowFPS;
5320 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5321 return D_O_K;
5322 }
5323
5324 1095828004 bool is_Fkey(int32_t k)
5325 {
5326
2/2
✓ Branch 0 taken 111440136 times.
✓ Branch 1 taken 984387868 times.
1095828004 switch(k)
5327 {
5328 case KEY_F1:
5329 case KEY_F2:
5330 case KEY_F3:
5331 case KEY_F4:
5332 case KEY_F5:
5333 case KEY_F6:
5334 case KEY_F7:
5335 case KEY_F8:
5336 case KEY_F9:
5337 case KEY_F10:
5338 case KEY_F11:
5339 case KEY_F12:
5340 111440136 return true;
5341 }
5342
5343 984387868 return false;
5344 1095828004 }
5345
5346 void kb_getkey(DIALOG *d);
5347
5348 //Used by all keyboard key settings dialogues.
5349 void kb_clearjoystick(DIALOG *d)
5350 {
5351 d->flags|=D_SELECTED;
5352
5353 jwin_button_proc(MSG_DRAW,d,0);
5354 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5355 // text_mode(vc(11));
5356 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5357 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5358
5359 update_hw_screen(true);
5360
5361 clear_keybuf();
5362 int32_t k = next_press_key();
5363 clear_keybuf();
5364
5365 //shnarf
5366 //47=f1
5367 //59=esc
5368 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5369 // *((int32_t*)d->dp3) = k;
5370 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5371
5372
5373 d->flags&=~D_SELECTED;
5374 }
5375
5376 //Clears key to 0.
5377 //Used by all keyboard key settings dialogues.
5378 void kb_clearkey(DIALOG *d);
5379
5380 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5381 {
5382 switch(msg)
5383 {
5384 case MSG_KEY:
5385 case MSG_CLICK:
5386
5387 kb_clearjoystick(d);
5388
5389 while(gui_mouse_b())
5390 {
5391 clear_keybuf();
5392 rest(1);
5393 }
5394
5395 return D_REDRAW;
5396 }
5397
5398 return jwin_button_proc(msg,d,c);
5399 }
5400
5401 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5402 //Only used in keyboard settings dialogues to clear keys.
5403 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5404
5405 void j_getbtn(DIALOG *d)
5406 {
5407 d->flags|=D_SELECTED;
5408 jwin_button_proc(MSG_DRAW,d,0);
5409 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5410 // text_mode(vc(11));
5411 int32_t y = screen->h/2 - 12;
5412 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5413 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5414 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5415
5416 update_hw_screen(true);
5417
5418 int32_t b = next_joy_input(true);
5419
5420 if(b>=0)
5421 *((int32_t*)d->dp3) = b;
5422
5423 d->flags&=~D_SELECTED;
5424
5425 if (player)
5426 player->joy_on = TRUE;
5427 }
5428
5429 void j_getstick(DIALOG *d)
5430 {
5431 d->flags|=D_SELECTED;
5432 jwin_button_proc(MSG_DRAW,d,0);
5433 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5434 // text_mode(vc(11));
5435 int32_t y = screen->h/2 - 12;
5436 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5437 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5438 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5439
5440 update_hw_screen(true);
5441
5442 int32_t b = next_joy_input(false);
5443
5444 if(b>=0)
5445 *((int32_t*)d->dp3) = b;
5446
5447 d->flags&=~D_SELECTED;
5448
5449 if (player)
5450 player->joy_on = TRUE;
5451 }
5452
5453 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5454 {
5455 switch(msg)
5456 {
5457 case MSG_KEY:
5458 case MSG_CLICK:
5459
5460 j_getbtn(d);
5461
5462 while(gui_mouse_b()) {
5463 rest(1);
5464 clear_keybuf();
5465 }
5466
5467 return D_REDRAW;
5468 }
5469
5470 return jwin_button_proc(msg,d,c);
5471 }
5472
5473 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5474 {
5475 switch(msg)
5476 {
5477 case MSG_KEY:
5478 case MSG_CLICK:
5479
5480 j_getstick(d);
5481
5482 while(gui_mouse_b()) {
5483 rest(1);
5484 clear_keybuf();
5485 }
5486
5487 return D_REDRAW;
5488 }
5489
5490 return jwin_button_proc(msg,d,c);
5491 }
5492
5493 //shnarf
5494 extern const char *key_str[];
5495 std::string get_keystr(int key);
5496
5497 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5498 //extern int32_t zcmusic_bufsz;
5499
5500 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5501 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5502 str_primary_stick[80], str_secondary_stick[80];
5503
5504 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5505 {
5506 //these are here to bypass compiler warnings about unused arguments
5507 c=c;
5508
5509 if(msg==MSG_DRAW)
5510 {
5511 switch(d->w)
5512 {
5513 case 0:
5514 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5515 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5516 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5517 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5518 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5519 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5520 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5521 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5522 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5523 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5524 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5525 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5526 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5527 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5528 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5529 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5530 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5531 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5532 break;
5533
5534 case 1:
5535 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5536 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5537 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5538 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5539 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5540 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5541 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5542 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5543 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5544 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5545 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5546 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5547 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5548 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5549 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5550 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5551 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5552 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5553 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5554 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5555 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5556 break;
5557
5558 case 2:
5559 sprintf(str_a," %3d",midi_volume);
5560 sprintf(str_b," %3d",digi_volume);
5561 sprintf(str_l," %3d",emusic_volume);
5562 sprintf(str_m," %3dKB",zcmusic_bufsz);
5563 sprintf(str_r," %3d",sfx_volume);
5564 strcpy(str_s,pan_str[pan_style]);
5565 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5566 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5567 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5568 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5569 break;
5570 }
5571 }
5572
5573 return D_O_K;
5574 }
5575
5576 int32_t set_vol(void *dp3, int32_t d2)
5577 {
5578 switch(((int32_t*)dp3)[0])
5579 {
5580 case 0:
5581 midi_volume = zc_min(d2<<3,255);
5582 break;
5583
5584 case 1:
5585 digi_volume = zc_min(d2<<3,255);
5586 break;
5587
5588 case 2:
5589 emusic_volume = zc_min(d2<<3,255);
5590 break;
5591
5592 case 3:
5593 sfx_volume = zc_min(d2<<3,255);
5594 break;
5595 }
5596
5597 // text_mode(vc(11));
5598 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5599 return D_O_K;
5600 }
5601
5602 int32_t set_pan(void *dp3, int32_t d2)
5603 {
5604 pan_style = vbound(d2,0,3);
5605 // text_mode(vc(11));
5606 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5607 return D_O_K;
5608 }
5609
5610 int32_t set_buf(void *dp3, int32_t d2)
5611 {
5612 // text_mode(vc(11));
5613 zcmusic_bufsz = d2 + 1;
5614 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5615 return D_O_K;
5616 }
5617
5618 static int32_t gamepad_joys_list[] =
5619 {
5620 61,
5621 -1
5622 };
5623
5624 static int32_t gamepad_btn_list[] =
5625 {
5626 6,
5627 7,8,9,10,11,12,13,14,15,16,17,
5628 18,19,20,21,22,23,24,25,26,27,28,
5629 29,30,31,32,33,34,35,36,37,38,39,
5630 -1
5631 };
5632
5633 static int32_t gamepad_dirs_list[] =
5634 {
5635 40,41,42,43,
5636 44,45,46,47,
5637 48,49,50,51,
5638 52,53,54,55,
5639 56,57,58,59,
5640 60,
5641 -1
5642 };
5643
5644 static TABPANEL gamepad_tabs[] =
5645 {
5646 // (text)
5647 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5648 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5649 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5650 { NULL, 0, NULL, 0, NULL }
5651 };
5652
5653 const char *joy_list(int32_t index, int32_t *list_size)
5654 {
5655 if (index == -1)
5656 {
5657 *list_size = al_get_num_joysticks();
5658 return NULL;
5659 }
5660
5661 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5662 if (!joy)
5663 {
5664 return "?";
5665 }
5666
5667 return al_get_joystick_name(joy);
5668 }
5669
5670 116 static ListData joy__list(joy_list, &font);
5671
5672 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5673 {
5674 int32_t d2 = d->d2;
5675 int32_t ret = jwin_droplist_proc(msg,d,c);
5676
5677 if(d2!=d->d2)
5678 {
5679 joystick_index = d->d2;
5680 ret |= D_REDRAW_ALL;
5681 }
5682
5683 return ret;
5684 }
5685
5686 static DIALOG gamepad_dlg[] =
5687 {
5688 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5689 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5690 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5691 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5692 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5693 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5694 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5695 // 6
5696 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5697 // 7
5698 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5699 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5700 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5701 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5702 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5703 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5704 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5705 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5706 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5707 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5708 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5709 // 18
5710 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5711 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5712 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5713 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5714 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5715 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5716 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5717 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5718 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5719 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5720 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5721 // 29
5722 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5723 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5724 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5725 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5726 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5727 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5728 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5729 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5730 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5731 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5732 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5733 // 40
5734 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5735 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5736 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5737 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5738 // 44
5739 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5740 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5741 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5742 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5743 // 48
5744 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5745 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5746 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5747 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5748 // 52
5749 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5750 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5751 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5752 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5753 // 56
5754 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5755 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5756 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5757 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5758 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5759
5760 // 61
5761 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5762
5763 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5764 };
5765
5766 static int32_t keyboard_keys_list[] =
5767 {
5768 6,7,8,9,10,
5769 11,12,13,14,15,16,17,18,19,20,
5770 21,22,23,24,25,26,27,28,29,30,
5771 31,32,33,34,35,36,37,38,39,40,
5772 -1
5773 };
5774
5775 static int32_t keyboard_dirs_list[] =
5776 {
5777 41,42,43,44,
5778 45,46,47,48,
5779 49,50,51,52,
5780 53,54,55,56,
5781 -1
5782 };
5783
5784 static int32_t keyboard_mods_list[] =
5785 {
5786 57,58,59,60,
5787 61,62,63,64,
5788 65,66,67,68,
5789 69,70,71,72,
5790 -1
5791 };
5792
5793 static TABPANEL keyboard_control_tabs[] =
5794 {
5795 // (text)
5796 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5797 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5798 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5799 { NULL, 0, NULL, 0, NULL }
5800 };
5801
5802 static DIALOG keyboard_control_dlg[] =
5803 {
5804 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5805 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5806 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5807 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5808 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5809 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5810 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5811 // Keys
5812 // 6
5813 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5814 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5815 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5816 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5817 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5818 // 11
5819 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5820 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5821 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5822 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5823 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5824 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5825 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5826 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5827 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5828 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5829 // 21
5830 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5831 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5832 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5833 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5834 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5835 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5836 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5837 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5838 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5839 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5840 // 31
5841 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5842 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5843 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5844 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5845 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5846 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5847 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5848 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5849 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5850 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5851 // Dirs
5852 // 41
5853 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5854 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5855 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5856 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5857 // 45
5858 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5859 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5860 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5861 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5862 // 49
5863 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5864 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5865 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5866 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5867 // 53
5868 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5869 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5870 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5871 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5872 // Mods
5873 // 57
5874 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5875 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5876 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5877 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5878 // 61
5879 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5880 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5881 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5882 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5883 // 65
5884 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5885 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5886 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5887 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5888 // 69
5889 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5890 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5891 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5892 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5893 // 73
5894 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5895 };
5896
5897 /*
5898 int32_t midi_dp[3] = {0,147,104};
5899 int32_t digi_dp[3] = {1,147,120};
5900 int32_t pan_dp[3] = {0,147,136};
5901 int32_t buf_dp[3] = {0,147,152};
5902 */
5903 int32_t midi_dp[3] = {0,0,0};
5904 int32_t digi_dp[3] = {1,0,0};
5905 int32_t emus_dp[3] = {2,0,0};
5906 int32_t buf_dp[3] = {0,0,0};
5907 int32_t sfx_dp[3] = {3,0,0};
5908 int32_t pan_dp[3] = {0,0,0};
5909
5910 static DIALOG sound_dlg[] =
5911 {
5912 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5913 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5914 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5915 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5916 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5917 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5918 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5919 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5920 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5921 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5922 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5923 // 10
5924 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5925 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5926 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5927 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5928 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5929 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5930 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5931 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5932 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5933 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5934 //20
5935 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5936 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5937 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5938 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5939 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5940 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5941 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5942 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5943 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5944 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5945 //30
5946 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5948 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5950 };
5951
5952 char zc_builddate[80];
5953 char zc_aboutstr[80];
5954
5955 static DIALOG about_dlg[] =
5956 {
5957 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5958 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5959 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5960 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5961 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5962 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5963 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5964 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5965 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5966 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5967 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5968 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5969 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5970 };
5971
5972
5973 static DIALOG quest_dlg[] =
5974 {
5975 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5976 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5977 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5978 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5979 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5980 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5981 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5982 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5983 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5984 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5985 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5986 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5987 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5988 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5989 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5990 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5991 };
5992
5993 static DIALOG triforce_dlg[] =
5994 {
5995 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5996 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5997 // 1
5998 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5999 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6000 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6001 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6002 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6003 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6004 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6005 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6006 // 9
6007 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6008 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6009 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6010 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6011 };
6012
6013 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6014 {
6015 go();
6016 int32_t ret=0;
6017 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6018 comeback();
6019 return ret != 0;
6020 }
6021
6022
6023 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6024 {
6025 if(def!=modulepath)
6026 strcpy(modulepath,def);
6027
6028 if(!usefilename)
6029 {
6030 int32_t i=(int32_t)strlen(modulepath);
6031
6032 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6033 modulepath[i--]=0;
6034 }
6035
6036 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6037 int32_t ret=0;
6038 int32_t sel=0;
6039
6040 if(list==NULL)
6041 {
6042 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6043 }
6044 else
6045 {
6046 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6047 }
6048
6049 return ret!=0;
6050 }
6051
6052 //The Dialogue that loads a ZMOD Module File
6053 int32_t zc_load_zmod_module_file()
6054 {
6055 if ( Playing )
6056 {
6057 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6058 return -1;
6059 }
6060 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6061 return D_CLOSE;
6062
6063 FILE *tempmodule = fopen(modulepath,"r");
6064
6065 if(tempmodule == NULL)
6066 {
6067 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6068 return -1;
6069 }
6070
6071
6072 //Set the module path:
6073 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6074 strcpy(moduledata.module_name, modulepath);
6075 al_trace("New Module Path is: %s \n", moduledata.module_name);
6076 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6077 zcm.init(true); //Load the module values.
6078 moduledata.refresh_title_screen = 1;
6079 // refresh_select_screen = 1;
6080 return D_O_K;
6081 }
6082
6083 static DIALOG module_info_dlg[] =
6084 {
6085 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6086
6087
6088 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6089 //1
6090 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6091 //2
6092 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6093 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6094 //4
6095 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6096 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6097 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6098 //7
6099
6100 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6101 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6102 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6103 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6104 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6105 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6106 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6107 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6108 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6109
6110 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6111 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6112 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6113 };
6114
6115 void about_zcplayer_module(const char *prompt,int32_t initialval)
6116 {
6117
6118 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6119 if ( moduledata.moduletitle[0] != 0 )
6120 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6121
6122 if ( moduledata.moduleauthor[0] != 0 )
6123 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6124
6125 if ( moduledata.moduleinfo0[0] != 0 )
6126 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6127 if ( moduledata.moduleinfo1[0] != 0 )
6128 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6129 if ( moduledata.moduleinfo2[0] != 0 )
6130 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6131 if ( moduledata.moduleinfo3[0] != 0 )
6132 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6133 if ( moduledata.moduleinfo4[0] != 0 )
6134 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6135
6136 char module_date[255];
6137 memset(module_date, 0, sizeof(module_date));
6138 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6139 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6140
6141
6142
6143 char module_vers[255];
6144 memset(module_vers, 0, sizeof(module_vers));
6145 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6146
6147
6148 //sprintf(tilecount,"%d",1);
6149
6150 char module_build[255];
6151 memset(module_build, 0, sizeof(module_build));
6152 if ( moduledata.modbeta )
6153 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6154 else
6155 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6156
6157 module_info_dlg[12].dp = (char*)module_date;
6158 module_info_dlg[13].dp = (char*)module_vers;
6159 module_info_dlg[14].dp = (char*)module_build;
6160
6161 large_dialog(module_info_dlg);
6162
6163 int32_t ret = do_zqdialog(module_info_dlg,-1);
6164 jwin_center_dialog(module_info_dlg);
6165
6166
6167 }
6168
6169 int32_t onAbout_ZCP_Module()
6170 {
6171 about_zcplayer_module("About Module (.zmod)", 0);
6172 return D_O_K;
6173 }
6174
6175 //New Modules Menu for 2.55+
6176 static MENU zcmodule_menu[] =
6177 {
6178 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6179 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6180
6181 { NULL, NULL, NULL, 0, NULL }
6182 };
6183
6184 int32_t onToggleRecordingNewSaves()
6185 {
6186 if (zc_get_config("zeldadx", "replay_new_saves", false))
6187 {
6188 zc_set_config("zeldadx", "replay_new_saves", false);
6189 }
6190 else
6191 {
6192 zc_set_config("zeldadx", "replay_new_saves", true);
6193 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6194 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6195 }
6196 return D_O_K;
6197 }
6198
6199 int32_t onToggleSnapshotAllFrames()
6200 {
6201 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6202 return D_O_K;
6203 }
6204
6205 int32_t onStopReplayOrRecord()
6206 {
6207 if (replay_is_replaying())
6208 {
6209 replay_quit();
6210 }
6211 else if (replay_get_mode() == ReplayMode::Record)
6212 {
6213 if (!replay_get_meta_bool("test_mode"))
6214 {
6215 jwin_alert("Recording", "You cannot stop recording a save file.",
6216 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6217 return D_CLOSE;
6218 }
6219
6220 if (jwin_alert("Stop Recording",
6221 "Save replay to disk and stop recording?",
6222 "This will stop the recording.",
6223 NULL,
6224 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6225 return D_CLOSE;
6226
6227 replay_save();
6228 replay_stop();
6229 }
6230 return D_O_K;
6231 }
6232
6233 static int32_t handle_on_load_replay(ReplayMode mode)
6234 {
6235 if (Playing)
6236 {
6237 if (jwin_alert("Replay - Warning!",
6238 "Loading a replay will exit the current game.",
6239 "All unsaved progress will be lost.",
6240 "Do you wish to continue?",
6241 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6242 return D_CLOSE;
6243 }
6244
6245 std::string mode_string = replay_mode_to_string(mode);
6246 mode_string[0] = std::toupper(mode_string[0]);
6247
6248 std::string line_1 = "Select a replay file to play back.";
6249 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6250 std::string line_3 = "You can stop the replay and take over manually any time.";
6251 if (mode == ReplayMode::Update)
6252 {
6253 line_1 = "Select a replay file to update.";
6254 line_2 = "WARNING: be sure to back up the zplay file";
6255 line_3 = "and verify that the updated replay works as expected!";
6256 }
6257
6258 if (jwin_alert(mode_string.c_str(),
6259 line_1.c_str(),
6260 line_2.c_str(),
6261 line_3.c_str(),
6262 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6263 {
6264 char replay_path[2048];
6265 strcpy(replay_path, "replays/");
6266 if (jwin_file_select_ex(
6267 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6268 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6269 return D_CLOSE;
6270
6271 replay_quit();
6272 load_replay_file_deferred(mode, replay_path);
6273 Quit = qRESET;
6274 return D_CLOSE;
6275 }
6276 return D_O_K;
6277 }
6278
6279 int32_t onLoadReplay()
6280 {
6281 return handle_on_load_replay(ReplayMode::Replay);
6282 }
6283
6284 int32_t onLoadReplayAssert()
6285 {
6286 return handle_on_load_replay(ReplayMode::Assert);
6287 }
6288
6289 int32_t onLoadReplayUpdate()
6290 {
6291 return handle_on_load_replay(ReplayMode::Update);
6292 }
6293
6294 int32_t onSaveReplay()
6295 {
6296 if (replay_get_mode() == ReplayMode::Record)
6297 {
6298 if (!replay_get_meta_bool("test_mode"))
6299 {
6300 if (jwin_alert("Save Replay",
6301 "This will save a copy of the replay up to this point.",
6302 "The official replay file will be untouched.",
6303 "Do you wish to continue?",
6304 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6305 return D_CLOSE;
6306
6307 char replay_path[2048];
6308 strcpy(replay_path, replay_get_replay_path().string().c_str());
6309 if (jwin_file_select_ex(
6310 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6311 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6312 return D_CLOSE;
6313
6314 if (fileexists(replay_path))
6315 {
6316 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6317 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6318 return D_CLOSE;
6319 }
6320
6321 replay_save(replay_path);
6322 }
6323 else
6324 {
6325 replay_save();
6326 }
6327 }
6328 return D_O_K;
6329 }
6330
6331 static MENU replay_menu[] =
6332 {
6333 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6334 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6335 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6336 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6337 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6338 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6339 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6340
6341 { NULL, NULL, NULL, 0, NULL }
6342 };
6343
6344 static DIALOG credits_dlg[] =
6345 {
6346 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6347 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6348 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6349 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6350 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6351 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6352 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6353 };
6354
6355 116 static ListData dmap_list(dmaplist, &font);
6356
6357 static DIALOG goto_dlg[] =
6358 {
6359 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6360 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6361 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6362 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6363 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6364 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6365 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6366 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6367 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6368 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6369 };
6370
6371 int32_t onGoTo()
6372 {
6373 bool music = false;
6374 music = music;
6375 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6376
6377 goto_dlg[0].dp2=get_zc_font(font_lfont);
6378 goto_dlg[4].d2=cheat_goto_dmap;
6379 goto_dlg[6].dp=cheat_goto_screen_str;
6380
6381 clear_keybuf();
6382
6383 large_dialog(goto_dlg);
6384
6385 if(do_zqdialog(goto_dlg,4)==1)
6386 {
6387 // dmap, screen
6388 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6389 };
6390
6391 return D_O_K;
6392 }
6393
6394 int32_t onGoToComplete()
6395 {
6396 if(!Playing)
6397 {
6398 return D_O_K;
6399 }
6400
6401 enter_sys_pal();
6402 music_pause();
6403 pause_all_sfx();
6404 onGoTo();
6405 eat_buttons();
6406
6407 zc_readrawkey(KEY_ESC);
6408
6409 exit_sys_pal();
6410 music_resume();
6411 resume_all_sfx();
6412 return D_O_K;
6413 }
6414
6415 int32_t onCredits()
6416 {
6417 go();
6418
6419 BITMAP *win = create_bitmap_ex(8,222,110);
6420
6421 if(!win)
6422 return D_O_K;
6423
6424 int32_t c=0;
6425 int32_t l=0;
6426 int32_t ol=-1;
6427 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6428 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6429 PALETTE tmppal;
6430
6431 rti_gui.transparency_index = 1;
6432
6433 clear_to_color(win, rti_gui.transparency_index);
6434 draw_rle_sprite(win,rle,0,0);
6435 credits_dlg[0].dp2=get_zc_font(font_lfont);
6436 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6437 credits_dlg[2].dp = win;
6438
6439 zc_set_palette_range(black_palette,0,127,false);
6440
6441 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6442
6443 BITMAP* old_screen = screen;
6444 BITMAP* gui_bmp = zc_get_gui_bmp();
6445 ASSERT(gui_bmp);
6446 clear_to_color(gui_bmp, rti_gui.transparency_index);
6447 screen = gui_bmp;
6448
6449 while(update_dialog(p))
6450 {
6451 throttleFPS();
6452 ++c;
6453 l = zc_max((c>>1)-30,0);
6454
6455 if(l > rle->h)
6456 l = c = 0;
6457
6458 if(l > rle->h - 112)
6459 l = rle->h - 112;
6460
6461 clear_bitmap(win);
6462 draw_rle_sprite(win,rle,0,0-l);
6463
6464 if(c<=64)
6465 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6466
6467 zc_set_palette_range(tmppal,0,127,false);
6468
6469 if(l!=ol)
6470 {
6471 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6472 SCRFIX();
6473 ol=l;
6474 }
6475
6476 update_hw_screen();
6477 }
6478
6479 screen = old_screen;
6480 system_pal(true);
6481 sys_mouse();
6482
6483 shutdown_dialog(p);
6484 destroy_bitmap(win);
6485 //comeback();
6486
6487 rti_gui.transparency_index = 0;
6488 clear_to_color(gui_bmp, rti_gui.transparency_index);
6489
6490 return D_O_K;
6491 }
6492
6493 const char *midilist(int32_t index, int32_t *list_size)
6494 {
6495 if(index<0)
6496 {
6497 *list_size=0;
6498
6499 for(int32_t i=0; i<MAXMIDIS; i++)
6500 if(tunes[i].data)
6501 ++(*list_size);
6502
6503 return NULL;
6504 }
6505
6506 int32_t i=0,m=0;
6507
6508 while(m<=index && i<=MAXMIDIS)
6509 {
6510 if(tunes[i].data)
6511 ++m;
6512
6513 ++i;
6514 }
6515
6516 --i;
6517
6518 if(i==MAXMIDIS && m<index)
6519 return "(null)";
6520
6521 return tunes[i].title;
6522 }
6523
6524 /* ------- MIDI info stuff -------- */
6525
6526 char *text;
6527 midi_info *zmi;
6528 bool dialog_running;
6529 bool listening;
6530
6531 void get_info(int32_t index);
6532
6533 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6534 {
6535 int32_t d2 = d->d2;
6536 int32_t ret = jwin_droplist_proc(msg,d,c);
6537
6538 if(d2!=d->d2)
6539 {
6540 get_info(d->d2);
6541 }
6542
6543 return ret;
6544 }
6545
6546 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6547 {
6548 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6549
6550 int32_t ret = jwin_button_proc(msg,d,c);
6551
6552 if(ret == D_CLOSE)
6553 {
6554 // get current midi index
6555 int32_t index = (d+(d->d1))->d2;
6556 int32_t i=0, m=0;
6557
6558 while(m<=index && i<=MAXMIDIS)
6559 {
6560 if(tunes[i].data)
6561 ++m;
6562
6563 ++i;
6564 }
6565
6566 --i;
6567 jukebox(i);
6568 listening = true;
6569 ret = D_O_K;
6570 }
6571
6572 return ret;
6573 }
6574
6575 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6576 {
6577 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6578
6579 int32_t ret = jwin_button_proc(msg,d,c);
6580
6581 if(ret == D_CLOSE)
6582 {
6583 // get current midi index
6584 int32_t index = (d+(d->d1))->d2;
6585 int32_t i=0, m=0;
6586
6587 while(m<=index && i<=MAXMIDIS)
6588 {
6589 if(tunes[i].data)
6590 ++m;
6591
6592 ++i;
6593 }
6594
6595 --i;
6596
6597 // get file name
6598
6599 int32_t sel=0;
6600 //struct ffblk f;
6601 char title[40] = "Save MIDI: ";
6602 char fname[2048];
6603 memset(fname,0,2048);
6604 static EXT_LIST list[] =
6605 {
6606 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6607 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6608 { NULL, NULL }
6609 };
6610
6611 strcpy(title+11, tunes[i].title);
6612 title[39] = '\0';
6613
6614 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6615 goto done;
6616
6617 if(exists(fname))
6618 {
6619 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6620 goto done;
6621 }
6622
6623 // save midi i
6624
6625 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6626 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6627
6628 done:
6629 chop_path(fname);
6630 ret = D_REDRAW;
6631 }
6632
6633 return ret;
6634 }
6635
6636 116 static ListData midi_list(midilist, &font);
6637
6638 static DIALOG midi_dlg[] =
6639 {
6640 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6641 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6642 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6643 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6644 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6645 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6646 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6647 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6648 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6649 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6650 };
6651
6652 void get_info(int32_t index)
6653 {
6654 int32_t i=0, m=0;
6655
6656 while(m<=index && i<=MAXMIDIS)
6657 {
6658 if(tunes[i].data)
6659 ++m;
6660
6661 ++i;
6662 }
6663
6664 --i;
6665
6666 if(i==MAXMIDIS && m<index)
6667 strcpy(text,"(null)");
6668 else
6669 {
6670 get_midi_info((MIDI*)tunes[i].data,zmi);
6671 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6672 }
6673
6674 midi_dlg[0].dp2=get_zc_font(font_lfont);
6675 midi_dlg[3].dp = text;
6676 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6677 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6678
6679 if(dialog_running)
6680 {
6681 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6682 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6683 }
6684 }
6685
6686 int32_t onMIDICredits()
6687 {
6688 text = (char*)malloc(4096);
6689 zmi = (midi_info*)malloc(sizeof(midi_info));
6690
6691 if(!text || !zmi)
6692 {
6693 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6694 return D_O_K;
6695 }
6696
6697 bool do_pause_midi = midi_pos >= 0 && currmidi;
6698 auto restore_midi = currmidi;
6699 if(do_pause_midi)
6700 {
6701 paused_midi_pos = midi_pos;
6702 stop_midi();
6703 midi_suspended = midissuspHALTED;
6704 }
6705
6706 midi_dlg[0].dp2=get_zc_font(font_lfont);
6707 midi_dlg[2].d1 = 0;
6708 midi_dlg[2].d2 = 0;
6709 midi_dlg[4].flags = D_EXIT;
6710 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6711
6712 listening = false;
6713 dialog_running=false;
6714 get_info(0);
6715
6716 dialog_running=true;
6717
6718 large_dialog(midi_dlg);
6719
6720 do_zqdialog(midi_dlg,0);
6721 dialog_running=false;
6722
6723 if(listening)
6724 music_stop();
6725
6726 if(do_pause_midi)
6727 {
6728 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6729 midi_suspended = midissuspRESUME;
6730 currmidi = restore_midi;
6731 midi_pos = paused_midi_pos;
6732 }
6733
6734 if(text) free(text);
6735 if(zmi) free(zmi);
6736 return D_O_K;
6737 }
6738
6739 int32_t onAbout()
6740 {
6741 char buf1[80]={0};
6742 std::ostringstream oss;
6743 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6744 oss << buf1 << '\n';
6745 sprintf(buf1, "%s", ALPHA_VER_STR);
6746 oss << buf1 << '\n';
6747 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6748 oss << buf1 << '\n';
6749 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6750 oss << buf1 << '\n';
6751 sprintf(buf1, "Tag: %s", getReleaseTag());
6752 oss << buf1 << '\n';
6753
6754 InfoDialog("About ZC", oss.str()).show();
6755 return D_O_K;
6756 }
6757
6758 int32_t onQuest()
6759 {
6760 char fname[100];
6761 strcpy(fname, get_filename(qstpath));
6762 quest_dlg[0].dp2=get_zc_font(font_lfont);
6763 quest_dlg[1].dp = fname;
6764
6765 if(QHeader.quest_number==0)
6766 sprintf(str_a,"Custom");
6767 else
6768 sprintf(str_a,"%d",QHeader.quest_number);
6769
6770 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6771
6772 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6773 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6774
6775 large_dialog(quest_dlg);
6776
6777 do_zqdialog(quest_dlg, 0);
6778 return D_O_K;
6779 }
6780
6781 void call_vidmode_dlg();
6782 int32_t onVidMode()
6783 {
6784 call_vidmode_dlg();
6785 return D_O_K;
6786 }
6787
6788 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6789 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6790 //Added an extra statement, so that if the key is cleared to 0, the cleared
6791 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6792
6793 void load_ukeys(int32_t* arr)
6794 {
6795 arr[ukey_a] = Akey;
6796 arr[ukey_b] = Bkey;
6797 arr[ukey_s] = Skey;
6798 arr[ukey_l] = Lkey;
6799 arr[ukey_r] = Rkey;
6800 arr[ukey_p] = Pkey;
6801 arr[ukey_ex1] = Exkey1;
6802 arr[ukey_ex2] = Exkey2;
6803 arr[ukey_ex3] = Exkey3;
6804 arr[ukey_ex4] = Exkey4;
6805 arr[ukey_du] = DUkey;
6806 arr[ukey_dd] = DDkey;
6807 arr[ukey_dl] = DLkey;
6808 arr[ukey_dr] = DRkey;
6809 arr[ukey_mod1a] = cheat_modifier_keys[0];
6810 arr[ukey_mod1b] = cheat_modifier_keys[1];
6811 arr[ukey_mod2a] = cheat_modifier_keys[2];
6812 arr[ukey_mod2b] = cheat_modifier_keys[3];
6813 };
6814
6815 static const char* ukey_names[] = {
6816 "A", "B", "Start", "L", "R", "Map",
6817 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6818 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6819 "Cheat Mod R1", "Cheat Mod R2",
6820 };
6821 std::string get_ukey_name(int32_t k)
6822 {
6823 if (k < num_ukey) return ukey_names[k];
6824 return "";
6825 }
6826
6827 int32_t onKeyboard()
6828 {
6829 int32_t a = Akey;
6830 int32_t b = Bkey;
6831 int32_t s = Skey;
6832 int32_t l = Lkey;
6833 int32_t r = Rkey;
6834 int32_t p = Pkey;
6835 int32_t ex1 = Exkey1;
6836 int32_t ex2 = Exkey2;
6837 int32_t ex3 = Exkey3;
6838 int32_t ex4 = Exkey4;
6839 int32_t du = DUkey;
6840 int32_t dd = DDkey;
6841 int32_t dl = DLkey;
6842 int32_t dr = DRkey;
6843 int32_t mod1a = cheat_modifier_keys[0];
6844 int32_t mod1b = cheat_modifier_keys[1];
6845 int32_t mod2a = cheat_modifier_keys[2];
6846 int32_t mod2b = cheat_modifier_keys[3];
6847 bool done=false;
6848 int32_t ret;
6849
6850 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6851
6852 large_dialog(keyboard_control_dlg);
6853
6854 while(!done)
6855 {
6856 ret = do_zqdialog(keyboard_control_dlg,3);
6857
6858 if(ret==3) // OK
6859 {
6860 int32_t ukeys[num_ukey];
6861 load_ukeys(ukeys);
6862 std::vector<std::string> uniqueError;
6863 for(int32_t q = 0; q < num_ukey; ++q)
6864 {
6865 for(int32_t p = q+1; p < num_ukey; ++p)
6866 {
6867 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6868 {
6869 char buf[64];
6870 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6871 std::string str(buf);
6872 uniqueError.push_back(str);
6873 }
6874 }
6875 }
6876 if(uniqueError.size() == 0)
6877 {
6878 done = true;
6879 save_control_configs(true);
6880 }
6881 else
6882 {
6883 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6884 box_out("Cannot have duplicate keybinds!"); box_eol();
6885 for(std::vector<std::string>::iterator it = uniqueError.begin();
6886 it != uniqueError.end(); ++it)
6887 {
6888 box_out((*it).c_str()); box_eol();
6889 }
6890 box_end(true);
6891 }
6892 }
6893 else // Cancel
6894 {
6895 Akey = a;
6896 Bkey = b;
6897 Skey = s;
6898 Lkey = l;
6899 Rkey = r;
6900 Pkey = p;
6901 Exkey1 = ex1;
6902 Exkey2 = ex2;
6903 Exkey3 = ex3;
6904 Exkey4 = ex4;
6905 DUkey = du;
6906 DDkey = dd;
6907 DLkey = dl;
6908 DRkey = dr;
6909 cheat_modifier_keys[0] = mod1a;
6910 cheat_modifier_keys[1] = mod1b;
6911 cheat_modifier_keys[2] = mod2a;
6912 cheat_modifier_keys[3] = mod2b;
6913
6914 done=true;
6915 }
6916
6917 rest(1);
6918 }
6919
6920 return D_O_K;
6921 }
6922
6923 int32_t onGamepad()
6924 {
6925 int32_t a = Abtn;
6926 int32_t b = Bbtn;
6927 int32_t s = Sbtn;
6928 int32_t l = Lbtn;
6929 int32_t r = Rbtn;
6930 int32_t m = Mbtn;
6931 int32_t p = Pbtn;
6932 int32_t ex1 = Exbtn1;
6933 int32_t ex2 = Exbtn2;
6934 int32_t ex3 = Exbtn3;
6935 int32_t ex4 = Exbtn4;
6936 int32_t up = DUbtn;
6937 int32_t down = DDbtn;
6938 int32_t left = DLbtn;
6939 int32_t right = DRbtn;
6940 int32_t joy = joystick_index;
6941 int32_t stick_1 = js_stick_1_x_stick;
6942 int32_t stick_2 = js_stick_2_x_stick;
6943
6944 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6945 if(analog_movement)
6946 gamepad_dlg[56].flags|=D_SELECTED;
6947 else
6948 gamepad_dlg[56].flags&=~D_SELECTED;
6949
6950 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6951 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6952 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6953 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6954 // requires remapping every time.
6955 if (joystick_index >= al_get_num_joysticks())
6956 joystick_index = 0;
6957 gamepad_dlg[61].d2 = joystick_index;
6958
6959 large_dialog(gamepad_dlg);
6960
6961 int32_t ret = do_zqdialog(gamepad_dlg,4);
6962
6963 if(ret == 4) //OK
6964 {
6965 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6966 joystick_index = gamepad_dlg[61].d2;
6967 js_stick_1_y_stick = js_stick_1_x_stick;
6968 js_stick_2_y_stick = js_stick_2_x_stick;
6969 save_control_configs(false);
6970 }
6971 else //Cancel
6972 {
6973 Abtn = a;
6974 Bbtn = b;
6975 Sbtn = s;
6976 Lbtn = l;
6977 Rbtn = r;
6978 Mbtn = m;
6979 Pbtn = p;
6980 Exbtn1 = ex1;
6981 Exbtn2 = ex2;
6982 Exbtn3 = ex3;
6983 Exbtn4 = ex4;
6984 DUbtn = up;
6985 DDbtn = down;
6986 DLbtn = left;
6987 DRbtn = right;
6988 joystick_index = joy;
6989 js_stick_1_x_stick = stick_1;
6990 js_stick_2_x_stick = stick_2;
6991 }
6992
6993 return D_O_K;
6994 }
6995
6996 int32_t onCheatKeys()
6997 {
6998 int32_t oldcheats[Cheat::Last][2];
6999 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
7000
7001 bool done=false;
7002
7003 while(!done)
7004 {
7005 bool confirm = false;
7006 CheatKeysDialog(&confirm).show();
7007 if(confirm) // OK
7008 {
7009 std::vector<std::string> uniqueError;
7010 char buf[512];
7011 for(size_t q = 1; q < Cheat::Last; ++q)
7012 {
7013 if(cheatkeys[q][1] && !cheatkeys[q][0])
7014 {
7015 cheatkeys[q][0] = cheatkeys[q][1];
7016 cheatkeys[q][1] = 0;
7017 }
7018 }
7019 for(size_t q = 1; q < Cheat::Last; ++q)
7020 {
7021 if(!bindable_cheat((Cheat)q)) continue;
7022 for(size_t p = q+1; p < Cheat::Last; ++p)
7023 {
7024 if(!bindable_cheat((Cheat)p)) continue;
7025 for(size_t q2 = 0; q2 <= 1; ++q2)
7026 for(size_t p2 = 0; p2 <= 1; ++p2)
7027 {
7028 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
7029 {
7030 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
7031 cheat_to_string((Cheat)q), q2?"Alt":"Main",
7032 cheat_to_string((Cheat)p), p2?"Alt":"Main",
7033 get_keystr(cheatkeys[q][q2])));
7034 }
7035 }
7036 }
7037 }
7038 if(uniqueError.size() == 0)
7039 {
7040 done = true;
7041 save_cheatkeys();
7042 }
7043 else
7044 {
7045 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7046 box_out("Cannot have duplicate keybinds!"); box_eol();
7047 for(std::vector<std::string>::iterator it = uniqueError.begin();
7048 it != uniqueError.end(); ++it)
7049 {
7050 box_out((*it).c_str()); box_eol();
7051 }
7052 box_end(true);
7053 }
7054 }
7055 else // Cancel
7056 {
7057 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7058 done=true;
7059 }
7060 rest(1);
7061 }
7062
7063 return D_O_K;
7064 }
7065
7066 int32_t onSound()
7067 {
7068 if (get_qr(qr_OLD_SCRIPT_VOLUME))
7069 {
7070 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
7071 {
7072 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
7073 }
7074 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
7075 {
7076 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
7077 }
7078 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
7079 {
7080 emusic_volume = (int32_t)FFCore.usr_music_volume;
7081 }
7082 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
7083 {
7084 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7085 }
7086 }
7087 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7088 {
7089 pan_style = (int32_t)FFCore.usr_panstyle;
7090 }
7091
7092 int32_t m = midi_volume;
7093 int32_t d = digi_volume;
7094 int32_t e = emusic_volume;
7095 int32_t b = zcmusic_bufsz;
7096 int32_t s = sfx_volume;
7097 int32_t p = pan_style;
7098 pan_style = vbound(pan_style,0,3);
7099
7100 sound_dlg[0].dp2=get_zc_font(font_lfont);
7101
7102 large_dialog(sound_dlg);
7103
7104 midi_dp[1] = sound_dlg[6].x;
7105 midi_dp[2] = sound_dlg[6].y;
7106 digi_dp[1] = sound_dlg[7].x;
7107 digi_dp[2] = sound_dlg[7].y;
7108 emus_dp[1] = sound_dlg[8].x;
7109 emus_dp[2] = sound_dlg[8].y;
7110 buf_dp[1] = sound_dlg[9].x;
7111 buf_dp[2] = sound_dlg[9].y;
7112 sfx_dp[1] = sound_dlg[10].x;
7113 sfx_dp[2] = sound_dlg[10].y;
7114 pan_dp[1] = sound_dlg[11].x;
7115 pan_dp[2] = sound_dlg[11].y;
7116 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7117 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7118 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7119 sound_dlg[18].d2 = zcmusic_bufsz;
7120 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7121 sound_dlg[20].d2 = pan_style;
7122
7123 int32_t ret = do_zqdialog(sound_dlg,1);
7124
7125 if(ret==2)
7126 {
7127 master_volume(digi_volume,midi_volume);
7128 if (zcmusic)
7129 zcmusic_set_volume(zcmusic, emusic_volume);
7130
7131 int32_t temp_volume = sfx_volume;
7132 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
7133 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
7134 for(int32_t i=0; i<WAV_COUNT; ++i)
7135 {
7136 //allegro assertion fails when passing in -1 as voice -DD
7137 if(sfx_voice[i] > 0)
7138 voice_set_volume(sfx_voice[i], temp_volume);
7139 }
7140 zc_set_config(sfx_sect,"digi",digi_volume);
7141 zc_set_config(sfx_sect,"midi",midi_volume);
7142 zc_set_config(sfx_sect,"sfx",sfx_volume);
7143 zc_set_config(sfx_sect,"emusic",emusic_volume);
7144 zc_set_config(sfx_sect,"pan",pan_style);
7145 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7146 }
7147 else
7148 {
7149 midi_volume = m;
7150 digi_volume = d;
7151 emusic_volume = e;
7152 zcmusic_bufsz = b;
7153 sfx_volume = s;
7154 pan_style = p;
7155 }
7156
7157 return D_O_K;
7158 }
7159
7160 int32_t queding(char const* s1, char const* s2, char const* s3)
7161 {
7162 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7163 }
7164
7165 int32_t onQuit()
7166 {
7167 if(Playing)
7168 {
7169 int32_t ret=0;
7170
7171 if(get_qr(qr_NOCONTINUE))
7172 {
7173 if(standalone_mode)
7174 {
7175 ret=queding("End current game?",
7176 "The continue screen is disabled; the game",
7177 "will be reloaded from the last save.");
7178 }
7179 else
7180 {
7181 ret=queding("End current game?",
7182 "The continue screen is disabled. You will",
7183 "be returned to the file select screen.");
7184 }
7185 }
7186 else
7187 ret=queding("End current game?",NULL,NULL);
7188
7189 if(ret==1)
7190 {
7191 disableClickToFreeze=false;
7192 Quit=qQUIT;
7193
7194 // Trying to evade a door repair charge?
7195 if(repaircharge)
7196 {
7197 game->change_drupy(-repaircharge);
7198 repaircharge=0;
7199 }
7200
7201 return D_CLOSE;
7202 }
7203 }
7204
7205 return D_O_K;
7206 }
7207
7208 int32_t onTryQuitMenu()
7209 {
7210 return onTryQuit(true);
7211 }
7212
7213 int32_t onTryQuit(bool inMenu)
7214 {
7215 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7216 {
7217 if(active_cutscene.can_f6())
7218 {
7219 if(get_qr(qr_OLD_F6))
7220 {
7221 if(inMenu) onQuit();
7222 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7223 }
7224 else
7225 {
7226 disableClickToFreeze=false;
7227 GameFlags |= GAMEFLAG_TRYQUIT;
7228 }
7229 return D_CLOSE;
7230 }
7231 else active_cutscene.error();
7232 }
7233
7234 return D_O_K;
7235 }
7236
7237 int32_t onReset()
7238 {
7239 if(queding(" Reset system? ",NULL,NULL)==1)
7240 {
7241 disableClickToFreeze=false;
7242 Quit=qRESET;
7243 replay_quit();
7244 return D_CLOSE;
7245 }
7246
7247 return D_O_K;
7248 }
7249
7250 int32_t onExit()
7251 {
7252 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7253 {
7254 Quit=qEXIT;
7255 return D_CLOSE;
7256 }
7257
7258 return D_O_K;
7259 }
7260
7261 int32_t onDebug()
7262 {
7263 if(debug_enabled)
7264 set_debug(!get_debug());
7265 return D_O_K;
7266 }
7267
7268 int32_t onHeartBeep()
7269 {
7270 heart_beep=!heart_beep;
7271 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7272 return D_O_K;
7273 }
7274
7275 int32_t onSaveIndicator()
7276 {
7277 use_save_indicator = use_save_indicator ? 0 : 1;
7278 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7279 return D_O_K;
7280 }
7281
7282 int32_t onEpilepsy()
7283 {
7284 if(jwin_alert3(
7285 "Epilepsy Flash Reduction",
7286 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7287 "Disabling this will restore standard flash and wavy behaviour.",
7288 "Proceed?",
7289 "&Yes",
7290 "&No",
7291 NULL,
7292 'y',
7293 'n',
7294 0,
7295 get_zc_font(font_lfont)) == 1)
7296 {
7297 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7298 zc_set_config("zeldadx","checked_epilepsy",1);
7299 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7300 }
7301 return D_O_K;
7302 }
7303
7304 int32_t onTriforce()
7305 {
7306 for(int32_t i=0; i<MAXINITTABS; ++i)
7307 {
7308 init_tabs[i].flags&=~D_SELECTED;
7309 }
7310
7311 init_tabs[3].flags=D_SELECTED;
7312 return onCheatConsole();
7313 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7314 for(int32_t i=1; i<=8; i++)
7315 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7316
7317 if(do_zqdialog (triforce_dlg,-1)==9)
7318 {
7319 for(int32_t i=1; i<=8; i++)
7320 {
7321 game->lvlitems[i] &= ~liTRIFORCE;
7322 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7323 }
7324 }
7325 return D_O_K;*/
7326 }
7327
7328 bool rc = false;
7329 /*
7330 int32_t onEquipment()
7331 {
7332 for (int32_t i=0; i<MAXINITTABS; ++i)
7333 {
7334 init_tabs[i].flags&=~D_SELECTED;
7335 }
7336 init_tabs[0].flags=D_SELECTED;
7337 return onCheatConsole();
7338 }
7339 */
7340
7341 int32_t onItems()
7342 {
7343 for(int32_t i=0; i<MAXINITTABS; ++i)
7344 {
7345 init_tabs[i].flags&=~D_SELECTED;
7346 }
7347
7348 init_tabs[1].flags=D_SELECTED;
7349 return onCheatConsole();
7350 }
7351
7352 static DIALOG getnum_dlg[] =
7353 {
7354 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7355 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7356 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7357 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7358 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7359 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7360 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7361 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7362 };
7363
7364 int32_t getnumber(const char *prompt,int32_t initialval)
7365 {
7366 char buf[20];
7367 sprintf(buf,"%d",initialval);
7368 getnum_dlg[0].dp=(void *)prompt;
7369 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7370 getnum_dlg[2].dp=buf;
7371
7372 large_dialog(getnum_dlg);
7373
7374 if(do_zqdialog(getnum_dlg,2)==3)
7375 return atoi(buf);
7376
7377 return initialval;
7378 }
7379
7380 int32_t onLife()
7381 {
7382 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7383 cheats_enqueue(Cheat::Life, value);
7384 return D_O_K;
7385 }
7386
7387 int32_t onHeartC()
7388 {
7389 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7390 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7391 cheats_enqueue(Cheat::MaxLife, max_life);
7392 cheats_enqueue(Cheat::Life, life);
7393 return D_O_K;
7394 }
7395
7396 int32_t onMagicC()
7397 {
7398 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7399 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7400 cheats_enqueue(Cheat::MaxMagic, max_magic);
7401 cheats_enqueue(Cheat::Magic, magic);
7402 return D_O_K;
7403 }
7404
7405 int32_t onRupies()
7406 {
7407 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7408 cheats_enqueue(Cheat::Rupies, value);
7409 return D_O_K;
7410 }
7411
7412 int32_t onMaxBombs()
7413 {
7414 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7415 cheats_enqueue(Cheat::MaxBombs, value);
7416 cheats_enqueue(Cheat::Bombs, value);
7417 return D_O_K;
7418 }
7419
7420 int32_t onRefillLife()
7421 {
7422 cheats_enqueue(Cheat::Life, game->get_maxlife());
7423 return D_O_K;
7424 }
7425 int32_t onRefillMagic()
7426 {
7427 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7428 return D_O_K;
7429 }
7430 int32_t onClock()
7431 {
7432 cheats_enqueue(Cheat::Clock);
7433 return D_O_K;
7434 }
7435
7436 int32_t onQstPath()
7437 {
7438 char path[2048];
7439
7440 chop_path(qstdir);
7441 strcpy(path,qstdir);
7442
7443 go();
7444
7445 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7446 {
7447 chop_path(path);
7448 fix_filename_case(path);
7449 fix_filename_slashes(path);
7450 strcpy(qstdir,path);
7451 strcpy(qstpath,qstdir);
7452 }
7453
7454 comeback();
7455 return D_O_K;
7456 }
7457
7458 #include "dialog/cheat_dialog.h"
7459 int32_t onCheat()
7460 {
7461 call_setcheat_dialog();
7462 game->set_cheat(maxcheat);
7463 if(cheat) game->did_cheat(true);
7464 return D_O_K;
7465 }
7466
7467 int32_t onCheatRupies()
7468 {
7469 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7470 return D_O_K;
7471 }
7472
7473 int32_t onCheatArrows()
7474 {
7475 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7476 return D_O_K;
7477 }
7478
7479 int32_t onCheatBombs()
7480 {
7481 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7482 return D_O_K;
7483 }
7484
7485 // *** screen saver
7486
7487 9286678 int32_t after_time()
7488 {
7489
1/2
✓ Branch 0 taken 9286678 times.
✗ Branch 1 not taken.
9286678 if(ss_enable == 0)
7490 return INT_MAX;
7491
7492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 0)
7493 return 5 * 60;
7494
7495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 3)
7496 return ss_after * 15 * 60;
7497
7498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286678 times.
9286678 if(ss_after <= 13)
7499 return (ss_after - 3) * 60 * 60;
7500
7501 9286678 return MAX_IDLE + 1;
7502 9286678 }
7503
7504 static const char *after_str[15] =
7505 {
7506 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7507 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7508 "Never"
7509 };
7510
7511 const char *after_list(int32_t index, int32_t *list_size)
7512 {
7513 if(index < 0)
7514 {
7515 *list_size = 15;
7516 return NULL;
7517 }
7518
7519 return after_str[index];
7520 }
7521
7522 116 static ListData after__list(after_list, &font);
7523
7524 static DIALOG scrsaver_dlg[] =
7525 {
7526 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7527 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7528 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7529 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7530 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7531 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7532 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7533 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7534 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7535 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7536 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7537 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7538 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7539 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7540 };
7541
7542 int32_t onScreenSaver()
7543 {
7544 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7545 int32_t oldcfgs[3];
7546 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7547 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7548 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7549
7550 large_dialog(scrsaver_dlg);
7551
7552 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7553
7554 if(ret == 8 || ret == 9)
7555 {
7556 ss_after = scrsaver_dlg[5].d1;
7557 ss_speed = scrsaver_dlg[6].d2;
7558 ss_density = scrsaver_dlg[7].d2;
7559 if(oldcfgs[0] != ss_after)
7560 zc_set_config(cfg_sect,"ss_after",ss_after);
7561 if(oldcfgs[1] != ss_speed)
7562 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7563 if(oldcfgs[2] != ss_density)
7564 zc_set_config(cfg_sect,"ss_density",ss_density);
7565 }
7566
7567 if(ret == 9)
7568 // preview Screen Saver
7569 {
7570 clear_keybuf();
7571 Matrix(ss_speed, ss_density, 30);
7572 system_pal(true);
7573 sys_mouse();
7574 }
7575
7576 return D_O_K;
7577 }
7578
7579 /***** Menus *****/
7580
7581 static MENU game_menu[] =
7582 {
7583 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7584 { (char *)"", NULL, NULL, 0, NULL },
7585 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7586 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7587 { (char *)"", NULL, NULL, 0, NULL },
7588 #ifdef __EMSCRIPTEN__
7589 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7590 #elif defined(ALLEGRO_MACOSX)
7591 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7592 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7593 #else
7594 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7595 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7596 #endif
7597 { NULL, NULL, NULL, 0, NULL }
7598 };
7599
7600 static MENU snapshot_format_menu[] =
7601 {
7602 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7603 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7604 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7605 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7606 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7607 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7608 { NULL, NULL, NULL, 0, NULL }
7609 };
7610
7611 static MENU controls_menu[] =
7612 {
7613 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7614 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7615 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7616 { NULL, NULL, NULL, 0, NULL }
7617 };
7618
7619 static MENU name_entry_mode_menu[] =
7620 {
7621 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7622 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7623 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7624 { NULL, NULL, NULL, 0, NULL }
7625 };
7626
7627 static void set_controls_menu_active()
7628 {
7629
7630 }
7631
7632 static MENU window_menu[] =
7633 {
7634 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7635 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7636 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7637 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7638 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7639 { NULL, NULL, NULL, 0, NULL }
7640 };
7641 static MENU options_menu[] =
7642 {
7643 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7644 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7645 { "&Window Settings", NULL, window_menu, 0, NULL },
7646 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7647 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7648 { NULL, NULL, NULL, 0, NULL }
7649 };
7650 static MENU settings_menu[] =
7651 {
7652 { "&Sound...", onSound, NULL, 0, NULL },
7653 { "C&ontrols", NULL, controls_menu, 0, NULL },
7654 { "", NULL, NULL, 0, NULL },
7655 { "Options", NULL, options_menu, 0, NULL },
7656 { "", NULL, NULL, 0, NULL },
7657 //
7658 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7659 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7660 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7661 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7662 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7663 //
7664 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7665 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7666 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7667 { "", NULL, NULL, 0, NULL },
7668 { "Debu&g", onDebug, NULL, 0, NULL },
7669 //
7670 { NULL, NULL, NULL, 0, NULL }
7671 };
7672
7673
7674 static MENU misc_menu[] =
7675 {
7676 { (char *)"&About...", onAbout, NULL, 0, NULL },
7677 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7678 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7679 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7680 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7681 { (char *)"", NULL, NULL, 0, NULL },
7682 //5
7683 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7684 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7685 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7686 { (char *)"", NULL, NULL, 0, NULL },
7687 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7688 //10
7689 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7690 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7691 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7692 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7693 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7694 //15
7695 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7696 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7697 { NULL, NULL, NULL, 0, NULL }
7698 };
7699
7700 static MENU refill_menu[] =
7701 {
7702 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7703 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7704 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7705 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7706 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7707 { NULL, NULL, NULL, 0, NULL }
7708 };
7709
7710 static MENU show_menu[] =
7711 {
7712 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7713 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7714 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7715 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7716 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7717 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7718 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7719 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7720 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7721 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7722 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7723 { (char *)"", NULL, NULL, 0, NULL },
7724 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7725 { (char *)"", NULL, NULL, 0, NULL },
7726 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7727 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7728 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7729 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7730 { NULL, NULL, NULL, 0, NULL }
7731 };
7732
7733 static MENU cheat_menu[] =
7734 {
7735 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7736 { (char *)"", NULL, NULL, 0, NULL },
7737 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7738 { (char *)"", NULL, NULL, 0, NULL },
7739 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7740 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7741 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7742 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7743 { (char *)"", NULL, NULL, 0, NULL },
7744 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7745 { (char *)"", NULL, NULL, 0, NULL },
7746 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7747 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7748 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7749 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7750 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7751 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7752 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7753 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7754 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7755 { NULL, NULL, NULL, 0, NULL }
7756 };
7757
7758 #if DEVLEVEL > 0
7759 int32_t devLogging();
7760 int32_t devDebug();
7761 int32_t devTimestmp();
7762 #if DEVLEVEL > 1
7763 int32_t setCheat();
7764 #endif //DEVLEVEL > 1
7765 enum
7766 {
7767 dv_log,
7768 // dv_dbg,
7769 dv_tmpstmp,
7770 #if DEVLEVEL > 1
7771 dv_nil,
7772 dv_setcheat,
7773 #endif //DEVLEVEL > 1
7774 dv_max
7775 };
7776 static MENU dev_menu[] =
7777 {
7778 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7779 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7780 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7781 #if DEVLEVEL > 1
7782 { (char *)"", NULL, NULL, 0, NULL },
7783 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7784 #endif //DEVLEVEL > 1
7785 { NULL, NULL, NULL, 0, NULL }
7786 };
7787 int32_t devLogging()
7788 {
7789 dev_logging = !dev_logging;
7790 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7791 return D_O_K;
7792 }
7793 // int32_t devDebug()
7794 // {
7795 // dev_debug = !dev_debug;
7796 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7797 // return D_O_K;
7798 // }
7799 int32_t devTimestmp()
7800 {
7801 dev_timestmp = !dev_timestmp;
7802 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7803 return D_O_K;
7804 }
7805 #if DEVLEVEL > 1
7806 int32_t setCheat()
7807 {
7808 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7809 return D_O_K;
7810 }
7811 #endif //DEVLEVEL > 1
7812 #endif //DEVLEVEL > 0
7813
7814 MENU the_player_menu[] =
7815 {
7816 { (char *)"&Game", NULL, game_menu, 0, NULL },
7817 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7818 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7819 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7820 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7821 #if DEVLEVEL > 0
7822 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7823 #endif
7824 { NULL, NULL, NULL, 0, NULL }
7825 };
7826 int32_t onPauseInBackground()
7827 {
7828 if(jwin_alert3(
7829 "Toggle Pause In Background",
7830 "This action will change whether ZC Player pauses when the window loses focus.",
7831 "",
7832 "Proceed?",
7833 "&Yes",
7834 "&No",
7835 NULL,
7836 'y',
7837 'n',
7838 0,
7839 get_zc_font(font_lfont)) == 1)
7840 {
7841 pause_in_background = pause_in_background ? 0 : 1;
7842 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7843 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7844 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7845 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7846 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7847 }
7848 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7849 return D_O_K;
7850 }
7851
7852 int32_t onKeyboardEntry()
7853 {
7854 NameEntryMode=0;
7855 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7856 return D_O_K;
7857 }
7858
7859 int32_t onLetterGridEntry()
7860 {
7861 NameEntryMode=1;
7862 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7863 return D_O_K;
7864 }
7865
7866 int32_t onExtLetterGridEntry()
7867 {
7868 NameEntryMode=2;
7869 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7870 return D_O_K;
7871 }
7872
7873 static BITMAP* oldscreen;
7874 int32_t onFullscreenMenu()
7875 {
7876 // super hacks
7877 screen = oldscreen;
7878 if (onFullscreen() == D_REDRAW)
7879 {
7880 oldscreen = screen;
7881 }
7882 screen = menu_bmp;
7883 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7884 return D_O_K;
7885 }
7886
7887 116 void fix_menu()
7888 {
7889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7890 116 settings_menu[13].text = NULL;
7891 116 }
7892
7893 static DIALOG system_dlg[] =
7894 {
7895 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7896 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7897 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7898 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7899 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7900 #ifndef ALLEGRO_MACOSX
7901 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7902 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7903 #else
7904 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7905 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7906 #endif
7907 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7908 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7909 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7910 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7911 };
7912
7913 void reset_snapshot_format_menu()
7914 {
7915 for(int32_t i=0; i<ssfmtMAX; ++i)
7916 {
7917 snapshot_format_menu[i].flags=0;
7918 }
7919 }
7920
7921 int32_t onSetSnapshotFormat()
7922 {
7923 switch(active_menu->text[1])
7924 {
7925 case 'B': //"&BMP"
7926 SnapshotFormat=0;
7927 break;
7928
7929 case 'G': //"&GIF"
7930 SnapshotFormat=1;
7931 break;
7932
7933 case 'J': //"&JPG"
7934 SnapshotFormat=2;
7935 break;
7936
7937 case 'P': //"&PNG"
7938 SnapshotFormat=3;
7939 break;
7940
7941 case 'C': //"PC&X"
7942 SnapshotFormat=4;
7943 break;
7944
7945 case 'T': //"&TGA"
7946 SnapshotFormat=5;
7947 break;
7948
7949 case 'L': //"&LBM"
7950 SnapshotFormat=6;
7951 break;
7952 }
7953 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7954
7955 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7956 return D_O_K;
7957 }
7958
7959
7960 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7961 {
7962 PALETTE tmp;
7963
7964 for(int32_t i=0; i<256; i++)
7965 {
7966 tmp[i].r=r;
7967 tmp[i].g=g;
7968 tmp[i].b=b;
7969 }
7970
7971 fade_interpolate(src,tmp,dest,pos,from,to);
7972 }
7973
7974 14 void system_pal(bool force)
7975 {
7976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7977 14 is_sys_pal = true;
7978 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7979 14 hw_palette = &syspal;
7980 14 update_hw_pal = true;
7981 14 }
7982
7983 static uint32_t entered_sys_pal = 0;
7984 14 void enter_sys_pal()
7985 {
7986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7987 {
7988 if(entered_sys_pal)
7989 ++entered_sys_pal;
7990 return;
7991 }
7992 14 sys_mouse();
7993 14 system_pal(true);
7994 14 ++entered_sys_pal;
7995 14 }
7996 14 void exit_sys_pal()
7997 {
7998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7999 {
8000
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8001 {
8002 14 game_pal();
8003 14 game_mouse();
8004 14 }
8005 14 }
8006 14 }
8007
8008 void switch_out_callback()
8009 {
8010 if (pause_in_background && !MenuOpen)
8011 {
8012 System();
8013 }
8014 }
8015
8016 void switch_in_callback()
8017 {
8018 }
8019
8020 423 void game_pal()
8021 {
8022 423 is_sys_pal = false;
8023 423 entered_sys_pal = 0;
8024 423 hw_palette = &RAMpal;
8025 423 update_hw_pal = true;
8026 423 }
8027
8028 static char bar_str[] = "";
8029
8030 14 void music_pause()
8031 {
8032 //al_pause_duh(tmplayer);
8033 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
8035 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
8036 14 zc_midi_pause();
8037 14 }
8038
8039 void music_resume()
8040 {
8041 //al_resume_duh(tmplayer);
8042 zcmusic_pause(zcmusic, ZCM_RESUME);
8043 if (zcmixer->oldtrack)
8044 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
8045 zc_midi_resume();
8046 }
8047
8048 3360 void music_stop()
8049 {
8050 //al_stop_duh(tmplayer);
8051 //unload_duh(tmusic);
8052 //tmusic=NULL;
8053 //tmplayer=NULL;
8054 3360 zcmusic_stop(zcmusic);
8055 3360 zcmusic_unload_file(zcmusic);
8056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if (zcmixer->oldtrack)
8057 {
8058 zcmusic_stop(zcmixer->oldtrack);
8059 zcmusic_unload_file(zcmixer->oldtrack);
8060 }
8061 3360 zcmixer->newtrack = NULL;
8062 3360 zc_stop_midi();
8063 3360 currmidi=-1;
8064 3360 }
8065
8066 void System()
8067 {
8068 mouse_down=gui_mouse_b();
8069 music_pause();
8070 pause_all_sfx();
8071 MenuOpen = true;
8072 enter_sys_pal();
8073 // FONT *oldfont=font;
8074 // font=tfont;
8075
8076 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8077 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8078
8079 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8080 #if DEVLEVEL > 1
8081 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8082 #endif
8083 game_menu[3].flags =
8084 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8085 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8086 clear_keybuf();
8087
8088 DIALOG_PLAYER *p;
8089
8090 clear_bitmap(menu_bmp);
8091 oldscreen = screen;
8092 screen = menu_bmp;
8093
8094 p = init_dialog(system_dlg,-1);
8095
8096 // drop the menu on startup if menu button pressed
8097 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8098 simulate_keypress(KEY_G << 8);
8099
8100 do
8101 {
8102 if(handle_close_btn_quit())
8103 break;
8104
8105 rest(17);
8106
8107 if(mouse_down && !gui_mouse_b())
8108 mouse_down=0;
8109
8110 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8111 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8112 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8113 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8114 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8115 settings_menu[10].flags = NESquit?D_SELECTED:0;
8116 settings_menu[11].flags = volkeys?D_SELECTED:0;
8117
8118 window_menu[0].flags = DragAspect?D_SELECTED:0;
8119 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8120 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8121 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8122 window_menu[4].flags = stretchGame?D_SELECTED:0;
8123
8124 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8125 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
8126
8127 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8128 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8129 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8130
8131 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8132 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8133 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8134
8135 bool nocheat = (replay_is_replaying() || !Playing
8136 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8137 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8138 cheat_menu[0].flags = 0;
8139 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
8140 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8141 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8142 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8143 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8144 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8145 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8146 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8147 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8148
8149 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8150 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8151 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8152 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8153 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8154 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8155 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8156 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8157 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8158 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8159 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8160 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8161 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8162 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8163 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8164
8165 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8166 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8167
8168 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8169 (char *)"Disable recording new saves" :
8170 (char *)"Enable recording new saves";
8171 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8172 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8173 (char *)"Stop recording" :
8174 (char *)"Stop replaying";
8175 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8176 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8177 (char *)"Disable snapshot all frames" :
8178 (char *)"Enable snapshot all frames";
8179
8180 reset_snapshot_format_menu();
8181 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8182
8183 if(debug_enabled)
8184 {
8185 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8186 }
8187
8188 if(gui_mouse_b() && !mouse_down)
8189 break;
8190
8191 // press menu to drop the menu
8192 if(rMbtn())
8193 simulate_keypress(KEY_G << 8);
8194
8195 if(input_idle(true) > after_time())
8196 // run Screeen Saver
8197 {
8198 // Screen saver enabled for now.
8199 clear_keybuf();
8200 Matrix(ss_speed, ss_density, 0);
8201 system_pal(true);
8202 sys_mouse();
8203 broadcast_dialog_message(MSG_DRAW, 0);
8204 }
8205
8206 update_hw_screen();
8207 }
8208 while(update_dialog(p));
8209
8210 screen = oldscreen;
8211
8212 // font=oldfont;
8213 mouse_down=gui_mouse_b();
8214 shutdown_dialog(p);
8215 MenuOpen = false;
8216 if(Quit)
8217 {
8218 kill_sfx();
8219 music_stop();
8220 update_hw_screen();
8221 }
8222 else
8223 {
8224 music_resume();
8225 resume_all_sfx();
8226
8227 if(rc)
8228 ringcolor(false);
8229 }
8230 exit_sys_pal();
8231
8232 eat_buttons();
8233
8234 rc=false;
8235 clear_keybuf();
8236 // text_mode(0);
8237 }
8238
8239 116 void fix_dialogs()
8240 {
8241 116 jwin_center_dialog(about_dlg);
8242 116 jwin_center_dialog(gamepad_dlg);
8243 116 jwin_center_dialog(credits_dlg);
8244 116 jwin_center_dialog(gamemode_dlg);
8245 116 jwin_center_dialog(getnum_dlg);
8246 116 jwin_center_dialog(goto_dlg);
8247 116 jwin_center_dialog(keyboard_control_dlg);
8248 116 jwin_center_dialog(midi_dlg);
8249 116 jwin_center_dialog(quest_dlg);
8250 116 jwin_center_dialog(scrsaver_dlg);
8251 116 jwin_center_dialog(sound_dlg);
8252 116 jwin_center_dialog(triforce_dlg);
8253
8254 // digi_dp[1] += scrx;
8255 // digi_dp[2] += scry;
8256 // midi_dp[1] += scrx;
8257 // midi_dp[2] += scry;
8258 // pan_dp[1] += scrx;
8259 // pan_dp[2] += scry;
8260 // emus_dp[1] += scrx;
8261 // emus_dp[2] += scry;
8262 // buf_dp[1] += scrx;
8263 // buf_dp[2] += scry;
8264 // sfx_dp[1] += scrx;
8265 // sfx_dp[2] += scry;
8266 116 }
8267
8268 /*****************************/
8269 /**** Custom Sound System ****/
8270 /*****************************/
8271
8272 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8273 {
8274
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8275 }
8276
8277 // Run an NSF, or a MIDI if the NSF is missing somehow.
8278 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8279 {
8280 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8281
8282 // Found it
8283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8284 {
8285 newzcmusic->fadevolume = 10000;
8286 newzcmusic->fadeoutframes = fadeoutframes;
8287
8288 zcmixer->newtrack = newzcmusic;
8289
8290 zcmusic_stop(zcmusic);
8291 zcmusic_unload_file(zcmusic);
8292 zc_stop_midi();
8293
8294 zcmusic=newzcmusic;
8295 int32_t temp_volume = emusic_volume;
8296 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8297 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8298 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8299 zcmusic_play(zcmusic, temp_volume);
8300
8301 if(track>0)
8302 zcmusic_change_track(zcmusic,track);
8303
8304 return true;
8305 }
8306
8307 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8308
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8309 70 jukebox(midi);
8310
8311 149 return false;
8312 149 }
8313
8314 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8315 {
8316 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8317 // Found it
8318 if(newzcmusic!=NULL)
8319 {
8320 zcmusic_stop(zcmusic);
8321 zcmusic_unload_file(zcmusic);
8322 zc_stop_midi();
8323
8324 zcmusic=newzcmusic;
8325 zcmusic_play(zcmusic, emusic_volume);
8326
8327 if(track>0)
8328 zcmusic_change_track(zcmusic,track);
8329
8330 return true;
8331 }
8332
8333 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8334 else if(midi>-1000)
8335 jukebox(midi);
8336
8337 return false;
8338 }
8339
8340 int32_t get_zcmusicpos()
8341 {
8342 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8343 return debugtracething;
8344 return 0;
8345 }
8346
8347 void set_zcmusicpos(int32_t position)
8348 {
8349 zcmusic_set_curpos(zcmusic, position);
8350 }
8351
8352 void set_zcmusicspeed(int32_t speed)
8353 {
8354 zcmusic_set_speed(zcmusic, speed);
8355 }
8356
8357 int32_t get_zcmusiclen()
8358 {
8359 return zcmusic_get_length(zcmusic);
8360 }
8361
8362 void set_zcmusicloop(double start, double end)
8363 {
8364 zcmusic_set_loop(zcmusic, start, end);
8365 }
8366
8367 63941 void jukebox(int32_t index,int32_t loop)
8368 {
8369
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8370 63941 return;
8371
8372 music_stop();
8373
8374 if(index<0) index=MAXMIDIS-1;
8375
8376 if(index>=MAXMIDIS) index=0;
8377
8378 music_stop();
8379
8380 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8381 // stuck notes when a song stops. This fixes it.
8382 if(strcmp(midi_driver->name, "DIGMID")==0)
8383 zc_set_volume(0, 0);
8384
8385 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8386 zc_play_midi((MIDI*)tunes[index].data,loop);
8387
8388 if(tunes[index].start>0)
8389 zc_midi_seek(tunes[index].start);
8390
8391 midi_loop_start = tunes[index].loop_start;
8392 midi_loop_end = tunes[index].loop_end;
8393
8394 currmidi=index;
8395 master_volume(digi_volume, midi_volume);
8396 //midi_paused=false;
8397 63941 }
8398
8399 63941 void jukebox(int32_t index)
8400 {
8401
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8402
8403
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8404
8405 // do nothing if it's already playing
8406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8407 {
8408 return;
8409 }
8410
8411 63941 jukebox(index,tunes[index].loop);
8412 63941 }
8413
8414 16 void play_DmapMusic()
8415 {
8416
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8417 16 return;
8418
8419 static char tfile[2048];
8420 static int32_t ttrack=0;
8421 bool domidi=false;
8422
8423 int32_t fadeoutframes = 0;
8424 if (zcmusic != NULL)
8425 fadeoutframes = zcmusic->fadeoutframes;
8426
8427 if(DMaps[currdmap].tmusic[0]!=0)
8428 {
8429 if(zcmusic==NULL ||
8430 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8431 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8432 {
8433 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8434 {
8435 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8436 {
8437 if (zcmusic != NULL)
8438 {
8439 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8440 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8441 }
8442 }
8443 }
8444 else
8445 {
8446 if (zcmusic != NULL)
8447 {
8448 zcmusic_stop(zcmusic);
8449 zcmusic_unload_file(zcmusic);
8450 zcmusic = NULL;
8451 zcmixer->newtrack = NULL;
8452 }
8453
8454 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8455 zcmixer->newtrack = zcmusic;
8456
8457 if (zcmusic != NULL)
8458 {
8459 zc_stop_midi();
8460 strcpy(tfile, DMaps[currdmap].tmusic);
8461 zcmusic_play(zcmusic, emusic_volume);
8462 int32_t temptracks = 0;
8463 temptracks = zcmusic_get_tracks(zcmusic);
8464 temptracks = (temptracks < 2) ? 1 : temptracks;
8465 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8466 zcmusic_change_track(zcmusic, ttrack);
8467 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8468 }
8469 else
8470 {
8471 tfile[0] = 0;
8472 domidi = true;
8473 }
8474 }
8475 }
8476 }
8477 else
8478 {
8479 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8480 {
8481 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8482 }
8483 else
8484 {
8485 domidi = true;
8486 }
8487 }
8488
8489 if(domidi)
8490 {
8491 int32_t m=DMaps[currdmap].midi;
8492
8493 switch(m)
8494 {
8495 case 1:
8496 jukebox(ZC_MIDI_OVERWORLD);
8497 break;
8498
8499 case 2:
8500 jukebox(ZC_MIDI_DUNGEON);
8501 break;
8502
8503 case 3:
8504 jukebox(ZC_MIDI_LEVEL9);
8505 break;
8506
8507 default:
8508 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8509 jukebox(m+MIDIOFFSET_DMAP);
8510 else
8511 music_stop();
8512 }
8513 }
8514 16 }
8515
8516 15754 void playLevelMusic()
8517 {
8518
1/2
✓ Branch 0 taken 15754 times.
✗ Branch 1 not taken.
15754 if (is_headless())
8519 15754 return;
8520
8521 int32_t m=tmpscr->screen_midi;
8522
8523 switch(m)
8524 {
8525 case -2:
8526 music_stop();
8527 break;
8528
8529 case -1:
8530 play_DmapMusic();
8531 break;
8532
8533 case 1:
8534 jukebox(ZC_MIDI_OVERWORLD);
8535 break;
8536
8537 case 2:
8538 jukebox(ZC_MIDI_DUNGEON);
8539 break;
8540
8541 case 3:
8542 jukebox(ZC_MIDI_LEVEL9);
8543 break;
8544
8545 default:
8546 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8547 jukebox(m+MIDIOFFSET_MAPSCR);
8548 else
8549 music_stop();
8550 }
8551 15754 }
8552
8553 116 void master_volume(int32_t dv,int32_t mv)
8554 {
8555
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8556
8557
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8558
8559
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8560 116 int32_t temp_vol = midi_volume;
8561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8562 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8563 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8564 116 }
8565
8566 /*****************/
8567 /***** SFX *****/
8568 /*****************/
8569
8570 // array of voices, one for each sfx sample in the data file
8571 // 0+ = voice #
8572 // -1 = voice not allocated
8573 116 void Z_init_sound()
8574 {
8575
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8576 29696 sfx_voice[i]=-1;
8577
8578
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8579 812 tunes[i].data = (MIDI*)mididata[i].dat;
8580
8581
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8582 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8583
8584 116 master_volume(digi_volume,midi_volume);
8585 116 }
8586
8587 // returns number of voices currently allocated
8588 int32_t sfx_count()
8589 {
8590 int32_t c=0;
8591
8592 for(int32_t i=0; i<WAV_COUNT; i++)
8593 if(sfx_voice[i]!=-1)
8594 ++c;
8595
8596 return c;
8597 }
8598
8599 // clean up finished samples
8600 9217934 void sfx_cleanup()
8601 {
8602
2/2
✓ Branch 0 taken 2359791104 times.
✓ Branch 1 taken 9217934 times.
2369009038 for(int32_t i=0; i<WAV_COUNT; i++)
8603
3/4
✓ Branch 0 taken 619766 times.
✓ Branch 1 taken 2359171338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619766 times.
2360410870 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8604 {
8605 619766 deallocate_voice(sfx_voice[i]);
8606 619766 sfx_voice[i]=-1;
8607 619766 }
8608 9217934 }
8609
8610 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8611 // if a voice is already allocated (and/or playing), then it just returns true
8612 // Returns true: voice is allocated
8613 // false: unsuccessful
8614 964184 bool sfx_init(int32_t index)
8615 {
8616 // check index
8617
3/4
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721795 times.
964184 if(index<=0 || index>=WAV_COUNT)
8618 242389 return false;
8619
8620
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619784 times.
721795 if(sfx_voice[index]==-1)
8621 {
8622
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409908 times.
619784 if(sfxdat)
8623 {
8624
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8625 {
8626 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8627 209876 }
8628 else
8629 {
8630 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8631 }
8632 209876 }
8633 else
8634 {
8635 409908 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8636 }
8637
8638 619784 int32_t temp_volume = sfx_volume;
8639
2/4
✓ Branch 0 taken 619784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619784 times.
✗ Branch 3 not taken.
619784 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8640 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8641 619784 voice_set_volume(sfx_voice[index], temp_volume);
8642 619784 }
8643
8644 721795 return sfx_voice[index] != -1;
8645 964184 }
8646
8647 int32_t sfx_get_default_freq(int32_t index)
8648 {
8649 if (sfxdat)
8650 {
8651 if (index < Z35)
8652 {
8653 return ((SAMPLE*)sfxdata[index].dat)->freq;
8654 }
8655 else
8656 {
8657 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8658 }
8659 }
8660 else
8661 {
8662 return customsfxdata[index].freq;
8663 }
8664 }
8665
8666 int32_t sfx_get_length(int32_t index)
8667 {
8668 if (sfxdat)
8669 {
8670 if (index < Z35)
8671 {
8672 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8673 }
8674 else
8675 {
8676 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8677 }
8678 }
8679 else
8680 {
8681 return int32_t(customsfxdata[index].len);
8682 }
8683 }
8684
8685 // plays an sfx sample
8686 964184 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8687 {
8688
2/2
✓ Branch 0 taken 721795 times.
✓ Branch 1 taken 242389 times.
964184 if(!sfx_init(index))
8689 242389 return;
8690
1/2
✓ Branch 0 taken 721795 times.
✗ Branch 1 not taken.
721795 if (!is_headless())
8691 {
8692 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8693 voice_set_pan(sfx_voice[index], pan);
8694
8695 // Only used by ZScript currently
8696 if (freq <= -1)
8697 {
8698 freq = sfx_get_default_freq(index);
8699 }
8700 voice_set_frequency(sfx_voice[index], freq);
8701
8702 // Only used by ZScript currently
8703 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8704 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8705 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8706 voice_set_volume(sfx_voice[index], temp_volume);
8707
8708 int32_t pos = voice_get_position(sfx_voice[index]);
8709
8710 if (restart) voice_set_position(sfx_voice[index], 0);
8711
8712 if (pos <= 0)
8713 voice_start(sfx_voice[index]);
8714 }
8715
8716
3/4
✓ Branch 0 taken 398004 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398004 times.
721795 if (restart && replay_is_debug())
8717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398004 times.
398004 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8718 964184 }
8719
8720 // true if sfx is allocated
8721 68052 bool sfx_allocated(int32_t index)
8722 {
8723
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8724 }
8725
8726 // start it (in loop mode) if it's not already playing,
8727 // otherwise adjust it to play in loop mode -DD
8728 178223 void cont_sfx(int32_t index)
8729 {
8730
1/2
✓ Branch 0 taken 178223 times.
✗ Branch 1 not taken.
178223 if (is_headless())
8731 178223 return;
8732
8733 if(!sfx_init(index))
8734 {
8735 return;
8736 }
8737
8738 if(voice_get_position(sfx_voice[index])<=0)
8739 {
8740 voice_set_position(sfx_voice[index],0);
8741 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8742 voice_start(sfx_voice[index]);
8743 }
8744 else
8745 {
8746 adjust_sfx(index, 128, true);
8747 }
8748 178223 }
8749
8750 // adjust parameters while playing
8751 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8752 {
8753
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8754 4075 return;
8755
8756 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8757 voice_set_pan(sfx_voice[index],pan);
8758 4075 }
8759
8760 // pauses a voice
8761 1725 void pause_sfx(int32_t index)
8762 {
8763
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8764 voice_stop(sfx_voice[index]);
8765 1725 }
8766
8767 // resumes a voice
8768 747 void resume_sfx(int32_t index)
8769 {
8770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8771 747 return;
8772
8773 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8774 voice_start(sfx_voice[index]);
8775 747 }
8776
8777 // pauses all active voices
8778 452 void pause_all_sfx()
8779 {
8780
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8781
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8782 1 voice_stop(sfx_voice[i]);
8783 452 }
8784
8785 // resumes all paused voices
8786 438 void resume_all_sfx()
8787 {
8788
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8789
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8790 voice_start(sfx_voice[i]);
8791 438 }
8792
8793 // stops an sfx and deallocates the voice
8794 7339145 void stop_sfx(int32_t index)
8795 {
8796
3/4
✓ Branch 0 taken 6190594 times.
✓ Branch 1 taken 1148551 times.
✓ Branch 2 taken 6190594 times.
✗ Branch 3 not taken.
7339145 if(index<=0 || index>=WAV_COUNT)
8797 1148551 return;
8798
8799
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6190582 times.
6190594 if(sfx_voice[index]!=-1)
8800 {
8801 12 deallocate_voice(sfx_voice[index]);
8802 12 sfx_voice[index]=-1;
8803 12 }
8804 7339145 }
8805
8806 // Stops SFX played by Hero's item of the given family
8807 128638 void stop_item_sfx(int32_t family)
8808 {
8809 128638 int32_t id=current_item_id(family);
8810
8811
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8812 128083 return;
8813
8814 555 stop_sfx(itemsbuf[id].usesound);
8815 128638 }
8816
8817 3222 void kill_sfx()
8818 {
8819
2/2
✓ Branch 0 taken 824832 times.
✓ Branch 1 taken 3222 times.
828054 for(int32_t i=0; i<WAV_COUNT; i++)
8820
2/2
✓ Branch 0 taken 824826 times.
✓ Branch 1 taken 6 times.
824838 if(sfx_voice[i]!=-1)
8821 {
8822 6 deallocate_voice(sfx_voice[i]);
8823 6 sfx_voice[i]=-1;
8824 6 }
8825 3222 }
8826
8827 659811 int32_t pan(int32_t x)
8828 {
8829
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8830 {
8831 case 0:
8832 return 128;
8833
8834 case 1:
8835 659811 return vbound((x>>1)+68,0,255);
8836
8837 case 2:
8838 return vbound(((x*3)>>2)+36,0,255);
8839 }
8840
8841 return vbound(x,0,255);
8842 659811 }
8843
8844 /*******************************/
8845 /******* Input Handlers ********/
8846 /*******************************/
8847
8848 25092836 bool joybtn(int32_t b)
8849 {
8850
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if(b == 0)
8851 return false;
8852
1/2
✓ Branch 0 taken 25092836 times.
✗ Branch 1 not taken.
25092836 if (b-1 >= joy[joystick_index].num_buttons)
8853 25092836 return false;
8854
8855 return joy[joystick_index].button[b-1].b !=0;
8856 25092836 }
8857
8858 bool joystick(int32_t s)
8859 {
8860 if(s < 0)
8861 return false;
8862 if (s >= joy[joystick_index].num_sticks)
8863 return false;
8864
8865 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8866 {
8867 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8868 return true;
8869 }
8870 return false;
8871 }
8872
8873 const char* joybtn_name(int32_t b)
8874 {
8875 if (b <= 0 || b > joy[joystick_index].num_buttons)
8876 return "";
8877
8878 return joy[joystick_index].button[b-1].name;
8879 }
8880
8881 const char* joystick_name(int32_t s)
8882 {
8883 if (s < 0 || s >= joy[joystick_index].num_sticks)
8884 return "";
8885
8886 return joy[joystick_index].stick[s].name;
8887 }
8888
8889 int32_t next_press_key();
8890
8891 int32_t next_joy_input(bool buttons)
8892 {
8893 clear_keybuf();
8894
8895 //first, we need to wait until they're pressing no buttons
8896 for(;;)
8897 {
8898 if(keypressed())
8899 {
8900 switch(readkey()>>8)
8901 {
8902 case KEY_ESC:
8903 return -1;
8904
8905 case KEY_SPACE:
8906 return 0;
8907 }
8908 }
8909
8910 poll_joystick();
8911 bool done = true;
8912
8913 if (buttons)
8914 {
8915 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8916 {
8917 if(joybtn(i)) done = false;
8918 }
8919 }
8920 else
8921 {
8922 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8923 {
8924 if(joystick(i)) done = false;
8925 }
8926 }
8927
8928 if(done) break;
8929 rest(1);
8930 }
8931
8932 //now, we need to wait for them to press any button
8933 for(;;)
8934 {
8935 if(keypressed())
8936 {
8937 switch(readkey()>>8)
8938 {
8939 case KEY_ESC:
8940 return -1;
8941
8942 case KEY_SPACE:
8943 return 0;
8944 }
8945 }
8946
8947 poll_joystick();
8948
8949 if (buttons)
8950 {
8951 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8952 {
8953 if(joybtn(i))
8954 return i;
8955 }
8956 }
8957 else
8958 {
8959 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8960 {
8961 if(joystick(i))
8962 return i;
8963 }
8964 }
8965 rest(1);
8966 }
8967 }
8968
8969 1205771 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8970 {
8971
2/2
✓ Branch 0 taken 1201420 times.
✓ Branch 1 taken 4351 times.
1205771 bool ret = btn && !flag;
8972 1205771 flag = rawbtn;
8973
8974 1205771 return ret;
8975 }
8976 190797304 static bool rButton(bool &btn, bool &flag)
8977 {
8978
2/2
✓ Branch 0 taken 183953390 times.
✓ Branch 1 taken 6843914 times.
190797304 bool ret = btn && !flag;
8979 190797304 flag = btn;
8980
8981 190797304 return ret;
8982 }
8983 2888985 static bool rButtonPeek(bool btn, bool flag)
8984 {
8985
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8986 {
8987 2685887 return false;
8988 }
8989
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8990 {
8991 17939 return true;
8992 }
8993
8994 185159 return false;
8995 2888985 }
8996
8997 // Updated only by keyboard/gamepad.
8998 // If in replay mode, this is set directly by the replay system.
8999 // This should never be read from directly - use control_state instead.
9000 bool raw_control_state[ZC_CONTROL_STATES];
9001
9002 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9003 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9004 // lasts until the next call to load_control_state.
9005 bool control_state[ZC_CONTROL_STATES];
9006 bool disable_control[ZC_CONTROL_STATES];
9007 bool drunk_toggle_state[11];
9008 bool disabledKeys[127];
9009 bool KeyInput[127];
9010 bool KeyPress[127];
9011
9012 bool key_current_frame[127];
9013 bool key_previous_frame[127];
9014
9015 static bool key_system[127];
9016 static bool key_system_previous[127];
9017 static bool key_system_press[127];
9018
9019 bool button_press[ZC_CONTROL_STATES];
9020 bool button_hold[ZC_CONTROL_STATES];
9021
9022 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9023 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9024 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9025 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9026 #define STICK_PRECISION 56 //define your own sensitivity
9027
9028 7800709 void load_control_state()
9029 {
9030 7800709 load_control_called_this_frame = true;
9031
9032
2/2
✓ Branch 0 taken 4833196 times.
✓ Branch 1 taken 2967513 times.
7800709 if (replay_version_check(8, 11))
9033 {
9034
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9035 53415234 down_control_states[i] = raw_control_state[i];
9036 2967513 }
9037
9038
1/2
✓ Branch 0 taken 7800709 times.
✗ Branch 1 not taken.
7800709 if (!replay_is_replaying())
9039 {
9040 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9041 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9042 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9043 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9044 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9045 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9046 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9047 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9048 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9049 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9050 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9051 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9052 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9053 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9054
9055 if(num_joysticks != 0)
9056 {
9057 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9058 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9059 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9060 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9061 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9062 }
9063 else
9064 {
9065 raw_control_state[14] = false;
9066 raw_control_state[15] = false;
9067 raw_control_state[16] = false;
9068 raw_control_state[17] = false;
9069 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9070 }
9071 }
9072
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7800706 times.
7800709 if (replay_is_active())
9073 {
9074
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6785491 times.
7800706 if (replay_get_version() < 3)
9075 1015215 replay_poll();
9076
3/4
✓ Branch 0 taken 6785491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5024116 times.
✓ Branch 3 taken 1761375 times.
6785491 else if (replay_is_replaying() && replay_get_version() < 6)
9077 1761375 replay_peek_input();
9078
3/4
✓ Branch 0 taken 5024116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056603 times.
✓ Branch 3 taken 2967513 times.
5024116 else if (replay_is_replaying() && replay_version_check(8, 11))
9079 2967513 replay_peek_input();
9080
2/2
✓ Branch 0 taken 6696416 times.
✓ Branch 1 taken 1104290 times.
7800706 if (replay_get_version() == 8)
9081 1104290 update_keys();
9082 7800706 }
9083
9084 // Some test replay files were made before a serious input bug was fixed, so instead
9085 // of re-doing them or tossing them out, just check for that zplay version.
9086
3/4
✓ Branch 0 taken 7800703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7678803 times.
7800709 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9087
2/2
✓ Branch 0 taken 140412654 times.
✓ Branch 1 taken 7800703 times.
148213357 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9088 {
9089 140412654 control_state[i] = raw_control_state[i];
9090
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90925344 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140412654 if (botched_input && !control_state[i])
9091 47077142 down_control_states[i] = false;
9092 140412654 }
9093 7800703 bool did_bad_cutscene_btn = false;
9094
2/2
✓ Branch 0 taken 7800703 times.
✓ Branch 1 taken 140412654 times.
148213357 for(int q = 0; q < 18; ++q)
9095
4/4
✓ Branch 0 taken 6464476 times.
✓ Branch 1 taken 133948178 times.
✓ Branch 2 taken 6463742 times.
✓ Branch 3 taken 734 times.
140413388 if(control_state[q] && !active_cutscene.can_button(q))
9096 {
9097 734 control_state[q] = false;
9098 734 did_bad_cutscene_btn = true;
9099 734 }
9100
2/2
✓ Branch 0 taken 7800188 times.
✓ Branch 1 taken 515 times.
7800703 if(did_bad_cutscene_btn)
9101 515 active_cutscene.error();
9102
9103 7800703 button_press[0]=rButton(control_state[0],button_hold[0]);
9104 7800703 button_press[1]=rButton(control_state[1],button_hold[1]);
9105 7800703 button_press[2]=rButton(control_state[2],button_hold[2]);
9106 7800703 button_press[3]=rButton(control_state[3],button_hold[3]);
9107 7800703 button_press[4]=rButton(control_state[4],button_hold[4]);
9108 7800703 button_press[5]=rButton(control_state[5],button_hold[5]);
9109 7800703 button_press[6]=rButton(control_state[6],button_hold[6]);
9110 7800703 button_press[7]=rButton(control_state[7],button_hold[7]);
9111 7800703 button_press[8]=rButton(control_state[8],button_hold[8]);
9112 7800703 button_press[9]=rButton(control_state[9],button_hold[9]);
9113 7800703 button_press[10]=rButton(control_state[10],button_hold[10]);
9114 7800703 button_press[11]=rButton(control_state[11],button_hold[11]);
9115 7800703 button_press[12]=rButton(control_state[12],button_hold[12]);
9116 7800703 button_press[13]=rButton(control_state[13],button_hold[13]);
9117 7800703 button_press[14]=rButton(control_state[14],button_hold[14]);
9118 7800703 button_press[15]=rButton(control_state[15],button_hold[15]);
9119 7800703 button_press[16]=rButton(control_state[16],button_hold[16]);
9120 7800703 button_press[17]=rButton(control_state[17],button_hold[17]);
9121 7800703 }
9122
9123 // Returns true if any game key is pressed. This is needed because keypressed()
9124 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9125 40248748 bool zc_key_pressed()
9126 //may also need to use zc_getrawkey
9127 {
9128
7/10
✓ Branch 0 taken 32596311 times.
✓ Branch 1 taken 7652437 times.
✓ Branch 2 taken 7652437 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7652437 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6396064 times.
✓ Branch 7 taken 6396064 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461637 times.
42710385 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9129
4/6
✓ Branch 0 taken 6396064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6396064 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843948 times.
✓ Branch 5 taken 4843948 times.
6396064 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9130
4/6
✓ Branch 0 taken 4843948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3143103 times.
✓ Branch 5 taken 3143103 times.
4843948 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9131
4/6
✓ Branch 0 taken 3143103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3143103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2732161 times.
✓ Branch 5 taken 2732161 times.
3143103 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9132
1/2
✓ Branch 0 taken 2732161 times.
✗ Branch 1 not taken.
2732161 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9133
3/4
✓ Branch 0 taken 2612754 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612754 times.
✗ Branch 3 not taken.
2732161 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9134
3/4
✓ Branch 0 taken 2493851 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493851 times.
✗ Branch 3 not taken.
2612754 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9135
3/4
✓ Branch 0 taken 2478706 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478706 times.
✗ Branch 3 not taken.
2493851 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9136
3/4
✓ Branch 0 taken 2465207 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2465207 times.
✗ Branch 3 not taken.
2478706 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9137
3/4
✓ Branch 0 taken 2462713 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462713 times.
✗ Branch 3 not taken.
2465207 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9138
3/4
✓ Branch 0 taken 2462495 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462495 times.
✗ Branch 3 not taken.
2462713 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9139
3/4
✓ Branch 0 taken 2461656 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2462495 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9140
2/4
✓ Branch 0 taken 2461656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461656 times.
✗ Branch 3 not taken.
2461656 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9141
2/2
✓ Branch 0 taken 2461637 times.
✓ Branch 1 taken 19 times.
2461656 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9142 72017663 return true;
9143
9144 2461637 return false;
9145 9286678 }
9146
9147 150327228 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9148 {
9149 150327228 bool ret = false, drunkstate = false, rawret = false;;
9150 150327228 bool* flag = &down_control_states[btn];
9151
2/7
✓ Branch 0 taken 141031213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9296015 times.
150327228 switch(btn)
9152 {
9153 case btnF12:
9154 ret = zc_getkey(KEY_F12, ignoreDisable);
9155 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9156 eatEntirely = false;
9157 break;
9158 case btnF11:
9159 ret = zc_getkey(KEY_F11, ignoreDisable);
9160 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9161 eatEntirely = false;
9162 break;
9163 case btnF5:
9164 ret = zc_getkey(KEY_F5, ignoreDisable);
9165 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9166 eatEntirely = false;
9167 break;
9168 case btnQ:
9169 ret = zc_getkey(KEY_Q, ignoreDisable);
9170 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9171 eatEntirely = false;
9172 break;
9173 case btnI:
9174 ret = zc_getkey(KEY_I, ignoreDisable);
9175 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9176 eatEntirely = false;
9177 break;
9178 case btnM:
9179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9296015 times.
9296015 if(FFCore.kb_typing_mode) return false;
9180 9296015 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9181 9296015 eatEntirely = false;
9182 9296015 break;
9183 default: //control_state[] index
9184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141031213 times.
141031213 if(FFCore.kb_typing_mode) return false;
9185
5/6
✓ Branch 0 taken 140231434 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2231197 times.
✓ Branch 3 taken 138000237 times.
✓ Branch 4 taken 2231197 times.
✗ Branch 5 not taken.
141031213 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9186
2/2
✓ Branch 0 taken 8035911 times.
✓ Branch 1 taken 132995302 times.
141031213 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9187
4/4
✓ Branch 0 taken 126864620 times.
✓ Branch 1 taken 14166593 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14163589 times.
155197806 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9188 141031213 rawret = raw_control_state[btn];
9189 141031213 }
9190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150327228 times.
150327228 assert(flag);
9191
2/2
✓ Branch 0 taken 95847822 times.
✓ Branch 1 taken 54479406 times.
150327228 if(press)
9192 {
9193
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51590421 times.
54479406 if(peek)
9194 2888985 ret = rButtonPeek(ret, *flag);
9195
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1205771 times.
51590421 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9196 1205771 else ret = rButton(ret, *flag, rawret);
9197 54479406 }
9198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150327228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150327228 if(eatEntirely && ret) control_state[btn] = false;
9199
3/4
✓ Branch 0 taken 112368335 times.
✓ Branch 1 taken 37958893 times.
✓ Branch 2 taken 112368335 times.
✗ Branch 3 not taken.
150327228 if(drunk && drunkstate) ret = !ret;
9200 150327228 return ret;
9201 150327228 }
9202
9203 7464828 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9204 {
9205 7464828 byte ret = 0;
9206
2/2
✓ Branch 0 taken 5485508 times.
✓ Branch 1 taken 1979320 times.
7464828 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9207
2/2
✓ Branch 0 taken 7334014 times.
✓ Branch 1 taken 130814 times.
7464828 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9208
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9209
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9210
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9211
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9212
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9213
2/2
✓ Branch 0 taken 7334139 times.
✓ Branch 1 taken 130689 times.
7464828 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9214 7464828 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9215 }
9216
9217 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9218 {
9219 1114 return intbtn&vals;
9220 }
9221
9222 1767383 bool Up()
9223 {
9224 1767383 return getInput(btnUp);
9225 }
9226 147167 bool Down()
9227 {
9228 147167 return getInput(btnDown);
9229 }
9230 257581 bool Left()
9231 {
9232 257581 return getInput(btnLeft);
9233 }
9234 286774 bool Right()
9235 {
9236 286774 return getInput(btnRight);
9237 }
9238 164908 bool cAbtn()
9239 {
9240 164908 return getInput(btnA);
9241 }
9242 1411891 bool cBbtn()
9243 {
9244 1411891 return getInput(btnB);
9245 }
9246 bool cSbtn()
9247 {
9248 return getInput(btnS);
9249 }
9250 68744 bool cLbtn()
9251 {
9252 68744 return getInput(btnL);
9253 }
9254 68744 bool cRbtn()
9255 {
9256 68744 return getInput(btnR);
9257 }
9258 bool cPbtn()
9259 {
9260 return getInput(btnP);
9261 }
9262 bool cEx1btn()
9263 {
9264 return getInput(btnEx1);
9265 }
9266 bool cEx2btn()
9267 {
9268 return getInput(btnEx2);
9269 }
9270 bool cEx3btn()
9271 {
9272 return getInput(btnEx3);
9273 }
9274 bool cEx4btn()
9275 {
9276 return getInput(btnEx4);
9277 }
9278 bool AxisUp()
9279 {
9280 return getInput(btnAxisUp);
9281 }
9282 bool AxisDown()
9283 {
9284 return getInput(btnAxisDown);
9285 }
9286 bool AxisLeft()
9287 {
9288 return getInput(btnAxisLeft);
9289 }
9290 bool AxisRight()
9291 {
9292 return getInput(btnAxisRight);
9293 }
9294
9295 bool cMbtn()
9296 {
9297 return getInput(btnM);
9298 }
9299 bool cF12()
9300 {
9301 return getInput(btnF12);
9302 }
9303 bool cF11()
9304 {
9305 return getInput(btnF11);
9306 }
9307 bool cF5()
9308 {
9309 return getInput(btnF5);
9310 }
9311 bool cQ()
9312 {
9313 return getInput(btnQ);
9314 }
9315 bool cI()
9316 {
9317 return getInput(btnI);
9318 }
9319
9320 130270 bool rUp()
9321 {
9322 130270 return getInput(btnUp, true);
9323 }
9324 130174 bool rDown()
9325 {
9326 130174 return getInput(btnDown, true);
9327 }
9328 130122 bool rLeft()
9329 {
9330 130122 return getInput(btnLeft, true);
9331 }
9332 129657 bool rRight()
9333 {
9334 129657 return getInput(btnRight, true);
9335 }
9336 1296 bool rAbtn()
9337 {
9338 1296 return getInput(btnA, true);
9339 }
9340 1296 bool rBbtn()
9341 {
9342 1296 return getInput(btnB, true);
9343 }
9344 7396643 bool rSbtn()
9345 {
9346 7396643 return getInput(btnS, true);
9347 }
9348 9286678 bool rMbtn()
9349 {
9350 9286678 return getInput(btnM, true);
9351 }
9352 129441 bool rLbtn()
9353 {
9354 129441 return getInput(btnL, true);
9355 }
9356 129436 bool rRbtn()
9357 {
9358 129436 return getInput(btnR, true);
9359 }
9360 7333107 bool rPbtn()
9361 {
9362 7333107 return getInput(btnP, true);
9363 }
9364 bool rEx1btn()
9365 {
9366 return getInput(btnEx1, true);
9367 }
9368 bool rEx2btn()
9369 {
9370 return getInput(btnEx2, true);
9371 }
9372 140087 bool rEx3btn()
9373 {
9374 140087 return getInput(btnEx3, true);
9375 }
9376 140087 bool rEx4btn()
9377 {
9378 140087 return getInput(btnEx4, true);
9379 }
9380 bool rAxisUp()
9381 {
9382 return getInput(btnAxisUp, true);
9383 }
9384 bool rAxisDown()
9385 {
9386 return getInput(btnAxisDown, true);
9387 }
9388 bool rAxisLeft()
9389 {
9390 return getInput(btnAxisLeft, true);
9391 }
9392 bool rAxisRight()
9393 {
9394 return getInput(btnAxisRight, true);
9395 }
9396
9397 bool rF11()
9398 {
9399 return getInput(btnF11, true);
9400 }
9401 bool rQ()
9402 {
9403 return getInput(btnQ, true);
9404 }
9405 bool rI()
9406 {
9407 return getInput(btnI, true);
9408 }
9409
9410 18226189 bool DrunkUp()
9411 {
9412 18226189 return getInput(btnUp, false, true);
9413 }
9414 16889179 bool DrunkDown()
9415 {
9416 16889179 return getInput(btnDown, false, true);
9417 }
9418 10288364 bool DrunkLeft()
9419 {
9420 10288364 return getInput(btnLeft, false, true);
9421 }
9422 8834095 bool DrunkRight()
9423 {
9424 8834095 return getInput(btnRight, false, true);
9425 }
9426 8035553 bool DrunkcAbtn()
9427 {
9428 8035553 return getInput(btnA, false, true);
9429 }
9430 8017001 bool DrunkcBbtn()
9431 {
9432 8017001 return getInput(btnB, false, true);
9433 }
9434 7263977 bool DrunkcEx1btn()
9435 {
9436 7263977 return getInput(btnEx1, false, true);
9437 }
9438 7263997 bool DrunkcEx2btn()
9439 {
9440 7263997 return getInput(btnEx2, false, true);
9441 }
9442 bool DrunkcSbtn()
9443 {
9444 return getInput(btnS, false, true);
9445 }
9446 bool DrunkcMbtn()
9447 {
9448 return getInput(btnM, false, true);
9449 }
9450 bool DrunkcLbtn()
9451 {
9452 return getInput(btnL, false, true);
9453 }
9454 bool DrunkcRbtn()
9455 {
9456 return getInput(btnR, false, true);
9457 }
9458 bool DrunkcPbtn()
9459 {
9460 return getInput(btnP, false, true);
9461 }
9462
9463 bool DrunkrUp()
9464 {
9465 return getInput(btnUp, true, true);
9466 }
9467 bool DrunkrDown()
9468 {
9469 return getInput(btnDown, true, true);
9470 }
9471 bool DrunkrLeft()
9472 {
9473 return getInput(btnLeft, true, true);
9474 }
9475 bool DrunkrRight()
9476 {
9477 return getInput(btnRight, true, true);
9478 }
9479 6081761 bool DrunkrAbtn()
9480 {
9481 6081761 return getInput(btnA, true, true);
9482 }
9483 6098593 bool DrunkrBbtn()
9484 {
9485 6098593 return getInput(btnB, true, true);
9486 }
9487 71669 bool DrunkrEx1btn()
9488 {
9489 71669 return getInput(btnEx1, true, true);
9490 }
9491 71662 bool DrunkrEx2btn()
9492 {
9493 71662 return getInput(btnEx2, true, true);
9494 }
9495 bool DrunkrEx3btn()
9496 {
9497 return getInput(btnEx3, true, true);
9498 }
9499 bool DrunkrEx4btn()
9500 {
9501 return getInput(btnEx4, true, true);
9502 }
9503 bool DrunkrSbtn()
9504 {
9505 return getInput(btnS, true, true);
9506 }
9507 bool DrunkrMbtn()
9508 {
9509 return getInput(btnM, true, true);
9510 }
9511 6688759 bool DrunkrLbtn()
9512 {
9513 6688759 return getInput(btnL, true, true);
9514 }
9515 6685284 bool DrunkrRbtn()
9516 {
9517 6685284 return getInput(btnR, true, true);
9518 }
9519 bool DrunkrPbtn()
9520 {
9521 return getInput(btnP, true, true);
9522 }
9523
9524 9337 void eat_buttons()
9525 {
9526 9337 getInput(btnA, true, false, true);
9527 9337 getInput(btnB, true, false, true);
9528 9337 getInput(btnS, true, false, true);
9529 9337 getInput(btnM, true, false, true);
9530 9337 getInput(btnL, true, false, true);
9531 9337 getInput(btnR, true, false, true);
9532 9337 getInput(btnP, true, false, true);
9533 9337 getInput(btnEx1, true, false, true);
9534 9337 getInput(btnEx2, true, false, true);
9535 9337 getInput(btnEx3, true, false, true);
9536 9337 getInput(btnEx4, true, false, true);
9537 9337 }
9538
9539 // Is true for the _first frame_ of a key press.
9540 // But! it is possible that a script manually sets the value of KeyPress,
9541 // in which case it will be restored to the "true" value based on `key_current_frame`
9542 // and `key_previous_frame` on the next frame.
9543 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9544 {
9545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9547 {
9548 case KEY_F7:
9549 case KEY_F8:
9550 case KEY_F9:
9551 return KeyPress[k];
9552
9553 default:
9554
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9555 }
9556 14 }
9557
9558 // Is true for _every frame_ a key is held down.
9559 // But! it is possible that a script manually sets the value of KeyInput,
9560 // in which case it will be restored to the "true" value based on `key_current_frame`
9561 // on the next frame.
9562 bool zc_getkey(int32_t k, bool ignoreDisable)
9563 {
9564 if(ignoreDisable) return KeyInput[k];
9565 switch(k)
9566 {
9567 case KEY_F7:
9568 case KEY_F8:
9569 case KEY_F9:
9570 return KeyInput[k];
9571
9572 default:
9573 return KeyInput[k] && !disabledKeys[k];
9574 }
9575 }
9576
9577 // Reads (and then clears) the current frame key state directly.
9578 // Scripts can also modify `key_current_frame`.
9579 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9580 {
9581
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9582 {
9583 2 _key[k]=key[k]=key_current_frame[k]=0;
9584 2 return true;
9585 }
9586 301 _key[k]=key[k]=key_current_frame[k]=0;
9587 301 return false;
9588 303 }
9589
9590 // Reads the current frame key state directly.
9591 // Scripts can also modify `key_current_frame`.
9592 63249747 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9593 {
9594
2/2
✓ Branch 0 taken 53963041 times.
✓ Branch 1 taken 9286706 times.
63249747 if(ignoreDisable) return key_current_frame[k];
9595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 switch(k)
9596 {
9597 case KEY_F7:
9598 case KEY_F8:
9599 case KEY_F9:
9600 return key_current_frame[k];
9601
9602 default:
9603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9286706 times.
9286706 return key_current_frame[k] && !disabledKeys[k];
9604 }
9605 63249747 }
9606
9607 // Only used for a handful of keys, like tilde and Function keys.
9608 // This state is never read within the game.
9609 // It exists so that all keyboard input still functions during replay,
9610 // without inadvertently doing things like toggling throttling if the player
9611 // presses ~
9612 9286678 bool zc_get_system_key(int32_t k)
9613 {
9614 9286678 return key_system[k];
9615 }
9616
9617 // True for the _first_ frame of a key press.
9618 83580102 bool zc_read_system_key(int32_t k)
9619 {
9620 83580102 return key_system_press[k];
9621 }
9622
9623 1179408106 bool is_system_key(int32_t k)
9624 {
9625
2/2
✓ Branch 0 taken 1095828004 times.
✓ Branch 1 taken 83580102 times.
1179408106 switch (k)
9626 {
9627 case KEY_BACKQUOTE:
9628 case KEY_CLOSEBRACE:
9629 case KEY_END:
9630 case KEY_HOME:
9631 case KEY_OPENBRACE:
9632 case KEY_PGDN:
9633 case KEY_PGUP:
9634 case KEY_TAB:
9635 case KEY_TILDE:
9636 83580102 return true;
9637 }
9638 1095828004 return is_Fkey(k);
9639 1179408106 }
9640
9641 9286678 void update_system_keys()
9642 {
9643
2/2
✓ Branch 0 taken 1179408106 times.
✓ Branch 1 taken 9286678 times.
1188694784 for (int32_t q = 0; q < 127; ++q)
9644 {
9645
2/2
✓ Branch 0 taken 195020238 times.
✓ Branch 1 taken 984387868 times.
1179408106 if (!is_system_key(q))
9646 984387868 continue;
9647
9648 195020238 key_system[q] = key[q];
9649
1/2
✓ Branch 0 taken 195020238 times.
✗ Branch 1 not taken.
195020238 key_system_press[q] = key_system[q] && !key_system_previous[q];
9650 195020238 key_system_previous[q] = key_system[q];
9651 195020238 }
9652 9286678 }
9653
9654 10390968 void update_keys()
9655 {
9656
2/2
✓ Branch 0 taken 1319652936 times.
✓ Branch 1 taken 10390968 times.
1330043904 for (int32_t q = 0; q < 127; ++q)
9657 {
9658 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9659
1/2
✓ Branch 0 taken 1319652936 times.
✗ Branch 1 not taken.
1319652936 if (!replay_is_replaying())
9660 key_current_frame[q] = key[q];
9661
9662
2/2
✓ Branch 0 taken 1309864938 times.
✓ Branch 1 taken 9787998 times.
1319652936 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9663 1319652936 KeyInput[q] = key_current_frame[q];
9664 1319652936 key_previous_frame[q] = key_current_frame[q];
9665 1319652936 }
9666 10390968 }
9667
9668 bool zc_disablekey(int32_t k, bool val)
9669 {
9670 switch(k)
9671 {
9672 case KEY_F7:
9673 case KEY_F8:
9674 case KEY_F9:
9675 return false;
9676
9677 default:
9678 disabledKeys[k] = val;
9679 return true;
9680 }
9681 }
9682
9683 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9684 {
9685 timer=timer;
9686 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9687 }
9688